git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [BUG] rebase --interactive silently overwrites ignored files
@ 2019-04-11 23:56 wh
  2019-04-12 16:30 ` Phillip Wood
  0 siblings, 1 reply; 4+ messages in thread
From: wh @ 2019-04-11 23:56 UTC (permalink / raw)
  To: git

I'm using git 2.20.1 from Debian. Git is usually careful not to
overwrite untracked files, including ignored files. But interactive
rebase doesn't detect this (non-interactive rebase works fine).

Reproduction:
-----

#!/bin/sh
mkdir upstream
cd upstream
git init
echo 1 >feature-1
git add feature-1
git commit -m "feature 1"

cd ..
git clone upstream local
cd local
# write some tools for our own convenience
echo ours >tools
echo /tools >>.git/info/exclude
# start working on a feature
git checkout -b f2
echo wip >feature-2
git add feature-2
git commit -m "wip"

cd ../upstream
# official tools are available
echo theirs >tools
git add tools
git commit -m "tools"

cd ../local
git fetch ../upstream master

# this would be okay
#git rebase FETCH_HEAD

# problem: overwrites tools silently
GIT_EDITOR=true git rebase -i FETCH_HEAD

cat tools

-----

Expected: `git rebase -i` fails because it would have to overwrite the
untracked "tools" file. Contents of tools file remains `ours`.

Actual: Contents of tools file becomes `theirs`.

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

* Re: [BUG] rebase --interactive silently overwrites ignored files
  2019-04-11 23:56 [BUG] rebase --interactive silently overwrites ignored files wh
@ 2019-04-12 16:30 ` Phillip Wood
  2019-04-14  1:59   ` wh
  0 siblings, 1 reply; 4+ messages in thread
From: Phillip Wood @ 2019-04-12 16:30 UTC (permalink / raw)
  To: wh, git

Hi

On 12/04/2019 00:56, wh wrote:
> I'm using git 2.20.1 from Debian. Git is usually careful not to
> overwrite untracked files, including ignored files.

Git normally overwrites ignored files, so I think in your example rebase 
-i is working as expected, I'm surprised that the am based rebase does 
not overwrite the ignored file. There has been some discussion about 
introducing 'precious' files that are ignored but protected in the same 
way as untracked files [1].

Best Wishes

Phillip

[1] https://public-inbox.org/git/20190409102649.22115-1-pclouds@gmail.com/

  But interactive
> rebase doesn't detect this (non-interactive rebase works fine).
> 
> Reproduction:
> -----
> 
> #!/bin/sh
> mkdir upstream
> cd upstream
> git init
> echo 1 >feature-1
> git add feature-1
> git commit -m "feature 1"
> 
> cd ..
> git clone upstream local
> cd local
> # write some tools for our own convenience
> echo ours >tools
> echo /tools >>.git/info/exclude
> # start working on a feature
> git checkout -b f2
> echo wip >feature-2
> git add feature-2
> git commit -m "wip"
> 
> cd ../upstream
> # official tools are available
> echo theirs >tools
> git add tools
> git commit -m "tools"
> 
> cd ../local
> git fetch ../upstream master
> 
> # this would be okay
> #git rebase FETCH_HEAD
> 
> # problem: overwrites tools silently
> GIT_EDITOR=true git rebase -i FETCH_HEAD
> 
> cat tools
> 
> -----
> 
> Expected: `git rebase -i` fails because it would have to overwrite the
> untracked "tools" file. Contents of tools file remains `ours`.
> 
> Actual: Contents of tools file becomes `theirs`.
> 

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

* Re: [BUG] rebase --interactive silently overwrites ignored files
  2019-04-12 16:30 ` Phillip Wood
@ 2019-04-14  1:59   ` wh
  2019-04-14 13:24     ` Phillip Wood
  0 siblings, 1 reply; 4+ messages in thread
From: wh @ 2019-04-14  1:59 UTC (permalink / raw)
  To: phillip.wood; +Cc: git

Thanks for the info about the upcoming "precious" attribute. Looks useful.

I didn't get the impression that Git normally overwrites ignored
files. I ran some more experiments:

git rebase FETCH_HEAD        # bails
git rebase -i FETCH_HEAD     # overwrites
git merge FETCH_HEAD         # bails
git reset --keep FETCH_HEAD  # bails
git reset --merge FETCH_HEAD # bails
git checkout FETCH_HEAD      # overwrites
# without feature 2 locally:
git merge FETCH_HEAD         # overwrites, fast-forwards
git merge --no-ff FETCH_HEAD # bails

On Fri, Apr 12, 2019 at 9:30 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi
>
> On 12/04/2019 00:56, wh wrote:
> > I'm using git 2.20.1 from Debian. Git is usually careful not to
> > overwrite untracked files, including ignored files.
>
> Git normally overwrites ignored files, so I think in your example rebase
> -i is working as expected, I'm surprised that the am based rebase does
> not overwrite the ignored file. There has been some discussion about
> introducing 'precious' files that are ignored but protected in the same
> way as untracked files [1].
>
> Best Wishes
>
> Phillip
>
> [1] https://public-inbox.org/git/20190409102649.22115-1-pclouds@gmail.com/
>
>   But interactive
> > rebase doesn't detect this (non-interactive rebase works fine).
> >
> > Reproduction:
> > -----
> >
> > #!/bin/sh
> > mkdir upstream
> > cd upstream
> > git init
> > echo 1 >feature-1
> > git add feature-1
> > git commit -m "feature 1"
> >
> > cd ..
> > git clone upstream local
> > cd local
> > # write some tools for our own convenience
> > echo ours >tools
> > echo /tools >>.git/info/exclude
> > # start working on a feature
> > git checkout -b f2
> > echo wip >feature-2
> > git add feature-2
> > git commit -m "wip"
> >
> > cd ../upstream
> > # official tools are available
> > echo theirs >tools
> > git add tools
> > git commit -m "tools"
> >
> > cd ../local
> > git fetch ../upstream master
> >
> > # this would be okay
> > #git rebase FETCH_HEAD
> >
> > # problem: overwrites tools silently
> > GIT_EDITOR=true git rebase -i FETCH_HEAD
> >
> > cat tools
> >
> > -----
> >
> > Expected: `git rebase -i` fails because it would have to overwrite the
> > untracked "tools" file. Contents of tools file remains `ours`.
> >
> > Actual: Contents of tools file becomes `theirs`.
> >

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

* Re: [BUG] rebase --interactive silently overwrites ignored files
  2019-04-14  1:59   ` wh
@ 2019-04-14 13:24     ` Phillip Wood
  0 siblings, 0 replies; 4+ messages in thread
From: Phillip Wood @ 2019-04-14 13:24 UTC (permalink / raw)
  To: wh, phillip.wood; +Cc: git

On 14/04/2019 02:59, wh wrote:
> Thanks for the info about the upcoming "precious" attribute. Looks useful.

Hmm, unfortunately it's not looking so hopeful now [1]

> I didn't get the impression that Git normally overwrites ignored
> files. I ran some more experiments:
> 
> git rebase FETCH_HEAD        # bails
> git rebase -i FETCH_HEAD     # overwrites
> git merge FETCH_HEAD         # bails
> git reset --keep FETCH_HEAD  # bails
> git reset --merge FETCH_HEAD # bails
> git checkout FETCH_HEAD      # overwrites
> # without feature 2 locally:
> git merge FETCH_HEAD         # overwrites, fast-forwards
> git merge --no-ff FETCH_HEAD # bails

Thanks for sharing that, I was assuming the other commands behaved like 
checkout, I'm intrigued that merge behaves differently to rebase -i as 
they use the same underlying machinery, I'm a bit snowed under at the 
moment but I'll try and take a look at what's going sometime in the not 
too distant future.

Best Wishes

Phillip

[1] 
https://public-inbox.org/git/CACsJy8AEZ-Lz6zgEsuNukvphB9TTa9FAC1gK05fhnie2xtfc9w@mail.gmail.com/T/#u
> On Fri, Apr 12, 2019 at 9:30 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>>
>> Hi
>>
>> On 12/04/2019 00:56, wh wrote:
>>> I'm using git 2.20.1 from Debian. Git is usually careful not to
>>> overwrite untracked files, including ignored files.
>>
>> Git normally overwrites ignored files, so I think in your example rebase
>> -i is working as expected, I'm surprised that the am based rebase does
>> not overwrite the ignored file. There has been some discussion about
>> introducing 'precious' files that are ignored but protected in the same
>> way as untracked files [1].
>>
>> Best Wishes
>>
>> Phillip
>>
>> [1] https://public-inbox.org/git/20190409102649.22115-1-pclouds@gmail.com/
>>
>>    But interactive
>>> rebase doesn't detect this (non-interactive rebase works fine).
>>>
>>> Reproduction:
>>> -----
>>>
>>> #!/bin/sh
>>> mkdir upstream
>>> cd upstream
>>> git init
>>> echo 1 >feature-1
>>> git add feature-1
>>> git commit -m "feature 1"
>>>
>>> cd ..
>>> git clone upstream local
>>> cd local
>>> # write some tools for our own convenience
>>> echo ours >tools
>>> echo /tools >>.git/info/exclude
>>> # start working on a feature
>>> git checkout -b f2
>>> echo wip >feature-2
>>> git add feature-2
>>> git commit -m "wip"
>>>
>>> cd ../upstream
>>> # official tools are available
>>> echo theirs >tools
>>> git add tools
>>> git commit -m "tools"
>>>
>>> cd ../local
>>> git fetch ../upstream master
>>>
>>> # this would be okay
>>> #git rebase FETCH_HEAD
>>>
>>> # problem: overwrites tools silently
>>> GIT_EDITOR=true git rebase -i FETCH_HEAD
>>>
>>> cat tools
>>>
>>> -----
>>>
>>> Expected: `git rebase -i` fails because it would have to overwrite the
>>> untracked "tools" file. Contents of tools file remains `ours`.
>>>
>>> Actual: Contents of tools file becomes `theirs`.
>>>

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 23:56 [BUG] rebase --interactive silently overwrites ignored files wh
2019-04-12 16:30 ` Phillip Wood
2019-04-14  1:59   ` wh
2019-04-14 13:24     ` Phillip Wood

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox