admin管理员组

文章数量:1405323

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);

本文标签: Why git diff during conflict move out and duplicate some codeStack Overflow