Why git diff during conflict move out and duplicate some code? - Stack Overflow

I got this merge conflict:my $schema = $translator->schema;my @tables = sort { ($result->{tables}

I got this merge conflict:

  my $schema = $translator->schema;
  my @tables = sort { ($result->{tables}{$a}{'order'} || 0) <=> ($result->{tables}{$b}{'order'} || 0) }
      keys %{ $result->{tables} };

<<<<<<< HEAD
  for my $table_name (@tables) {
    my $tdata = $result->{tables}{$table_name};
    my $table = $schema->add_table(
| parent of 1bfbcdad (Introduce and use Postgres in-database schemas)
  for my $table_name ( @tables ) {
      my $tdata =  $result->{tables}{ $table_name };
      my $table =  $schema->add_table(
          #schema => $tdata->{'schema_name'},
          name   => $tdata->{'table_name'},
      ) or die "Couldn't create table '$table_name': " . $schema->error;
=======
    for my $table_name ( @tables ) {
        my $tdata =  $result->{tables}{ $table_name };
        my $table =  $schema->add_table(
            schema_qualifier => $tdata->{'schema_name'},
            name             => $tdata->{'table_name'},
        ) or die "Couldn't create table '$table_name': " . $schema->error;
>>>>>>> 1bfbcdad (Introduce and use Postgres in-database schemas)

      #schema => $tdata->{'schema_name'},
      name => $tdata->{'table_name'},
    ) or die "Couldn't create table '$table_name': " . $schema->error;

    $table->extra(temporary => 1) if $tdata->{'temporary'};

I expect that this part will be at HEAD section:

      #schema => $tdata->{'schema_name'},
      name => $tdata->{'table_name'},
    ) or die "Couldn't create table '$table_name': " . $schema->error;

like this:

  my $schema = $translator->schema;
  my @tables = sort { ($result->{tables}{$a}{'order'} || 0) <=> ($result->{tables}{$b}{'order'} || 0) }
      keys %{ $result->{tables} };

<<<<<<< HEAD
  for my $table_name (@tables) {
    my $tdata = $result->{tables}{$table_name};
    my $table = $schema->add_table(
      #schema => $tdata->{'schema_name'},
      name => $tdata->{'table_name'},
    ) or die "Couldn't create table '$table_name': " . $schema->error;
| parent of 1bfbcdad (Introduce and use Postgres in-database schemas)
  for my $table_name ( @tables ) {
      my $tdata =  $result->{tables}{ $table_name };
      my $table =  $schema->add_table(
          #schema => $tdata->{'schema_name'},
          name   => $tdata->{'table_name'},
      ) or die "Couldn't create table '$table_name': " . $schema->error;
=======
    for my $table_name ( @tables ) {
        my $tdata =  $result->{tables}{ $table_name };
        my $table =  $schema->add_table(
            schema_qualifier => $tdata->{'schema_name'},
            name             => $tdata->{'table_name'},
        ) or die "Couldn't create table '$table_name': " . $schema->error;
>>>>>>> 1bfbcdad (Introduce and use Postgres in-database schemas)

    $table->extra(temporary => 1) if $tdata->{'temporary'};

Otherwise if I resolve this conflict by keeping theirs change that part of code will be duplicated:

  my $schema = $translator->schema;
  my @tables = sort { ($result->{tables}{$a}{'order'} || 0) <=> ($result->{tables}{$b}{'order'} || 0) }
      keys %{ $result->{tables} };

    for my $table_name ( @tables ) {
        my $tdata =  $result->{tables}{ $table_name };
        my $table =  $schema->add_table(
            schema_qualifier => $tdata->{'schema_name'},
            name             => $tdata->{'table_name'},
        ) or die "Couldn't create table '$table_name': " . $schema->error;

      #schema => $tdata->{'schema_name'},
      name => $tdata->{'table_name'},
    ) or die "Couldn't create table '$table_name': " . $schema->error;

    $table->extra(temporary => 1) if $tdata->{'temporary'};

Why this happens? And are there any options to prevent this to occur? Thank you

PS. git version 2.49.0

UPD

Here is another similar example, but now the duplicated code is before the merge conflict block (actually this is not expected diff and wrong):

  my ($from_field, $to_field, $options) = @_;

  die "Can't alter field in another table"
      if ($from_field->table->name ne $to_field->table->name);

<<<<<<< HEAD
  my $generator = _generator($options);
  my @out;
| parent of 1bfbcdad (Introduce and use Postgres in-database schemas)
    die "Can't alter field in another table"
        if($from_field->table->name ne $to_field->table->name);
=======
    die "Can't alter field in another table"
        if($from_field->table->qualified_name ne $to_field->table->qualified_name);
>>>>>>> 1bfbcdad (Introduce and use Postgres in-database schemas)

  # drop geometry column and constraints
  push @out, drop_geometry_column($from_field, $options), drop_geometry_constraints($from_field, $options),
      if is_geometry($from_field);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744301767a4567535.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信