All of lore.kernel.org
 help / color / mirror / Atom feed
* Amending merge commits?
@ 2014-07-25 22:03 Besen, David
  2014-07-25 22:11 ` David Besen
  2014-07-25 22:19 ` Jonathan Nieder
  0 siblings, 2 replies; 18+ messages in thread
From: Besen, David @ 2014-07-25 22:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]


Hi folks,

I think one of my coworkers has stumbled on a git bug -- if you amend a merge commit, and then pull, your amends are lost.

Is this expected behavior?

I've reproduced the problem in a script (attached).  I ran it against a couple of versions of git (1.7.1, 1.7.9, 1.8.4, 2.0.0) and in each case it seemed to lose the amend.

- Dave


[-- Attachment #2: amend-merge.sh --]
[-- Type: application/octet-stream, Size: 1061 bytes --]

#!/bin/bash

set -ex

if [ -z "$GIT" ]; then GIT=git; fi
GIT_MERGE_AUTOEDIT=no

# Clean up from the last run
rm -rf repo.git repo repo2 || :

# Set up a bare "remote" repo
$GIT init --bare repo.git

# Check out the "remote" repo
$GIT clone repo.git repo

# Add a commit
cd repo
echo "file" > file.txt
$GIT add file.txt
$GIT commit -m "Add file.txt"
$GIT push origin master

# Make a branch
$GIT checkout -b mybranch

# Add a commit on the branch
echo "mybranch" >> file.txt
$GIT add .
$GIT commit -m "Add 'mybranch' line"

# Go back to master
$GIT checkout master

# Merge in mybranch to create a merge commit
$GIT merge --no-ff mybranch

# Push that back
$GIT push

# Amend the merge commit
echo "amended" >> file.txt
$GIT add .
$GIT commit -C HEAD --amend

cd ..

# Make a second checkout
$GIT clone repo.git repo2
cd repo2

# Add some unrelated changes to be pulled
echo "repo2" > file2.txt
$GIT add .
$GIT commit -m "Add file2"
$GIT push

cd ..
cd repo

# Pull
$GIT pull --rebase

# Now, we expect the text "amended" to be in file.txt
grep amended file.txt

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: Amending merge commits?
@ 2014-07-28 21:47 Nico Williams
  2014-07-29  9:58 ` Sergei Organov
  0 siblings, 1 reply; 18+ messages in thread
From: Nico Williams @ 2014-07-28 21:47 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Sergei Organov, Besen, David, git

On Mon, Jul 28, 2014 at 3:00 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Sergei Organov wrote:
>
>> Is there any scenario at all where pull --rebase=true wins over
>> preserve?
>
> Basically always in my book. ;-)
>
> When people turn on 'pull --rebase', they are asking for a clean,
> simplified history where their changes are small discrete patches in a
> clump on top of upstream.

+1.  Words to develop by.

There are exceptions.  E.g., when you pull commits from multiple
[forked] upstreams, then you can't keep your local commits on top.

That exception aside, keeping all local commits "on top" by always
rebasing them onto the upstream is extremely useful: a) in simplifying
conflict resolution, b) making it easy to identify as-yet-unintegrated
local commits, c) making it easy to contribute local commits.

Nico
--

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-07-30 18:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25 22:03 Amending merge commits? Besen, David
2014-07-25 22:11 ` David Besen
2014-07-25 22:19 ` Jonathan Nieder
2014-07-25 22:23   ` Besen, David
2014-07-25 22:31     ` Jonathan Nieder
2014-07-28 19:37       ` Sergei Organov
2014-07-28 20:00         ` Jonathan Nieder
2014-07-28 20:53           ` Sergei Organov
2014-07-28 21:47 Nico Williams
2014-07-29  9:58 ` Sergei Organov
2014-07-29 15:44   ` Nico Williams
2014-07-29 19:29     ` Philip Oakley
2014-07-29 20:19       ` Nico Williams
2014-07-29 21:38         ` Philip Oakley
2014-07-29 22:07           ` Nico Williams
2014-07-30  8:42     ` Sergei Organov
2014-07-30 17:43       ` Nico Williams
2014-07-30 18:28         ` Sergei Organov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.