git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: rm and add, but not rename, of identical files

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 11, 2012, 16:53 UTC
Message-ID
<7v4nm17xxj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1349968240.32696.22.camel@drew-northup.unet.maine.edu>
Drew Northup <drew.northup@maine.edu> writes:
Show 35 quoted lines
> On Wed, 2012-10-10 at 14:47 -0700, Junio C Hamano wrote:
>> Drew Northup <drew.northup@maine.edu> writes:
>> 
>> > # Untracked files:
>> > #   (use "git add <file>..." to include in what will be committed)
>> > #
>> > #       rc.d/rc2.d/S08iptables
>> > #       rc.d/rc3.d/S08iptables
>> > #       rc.d/rc4.d/S08iptables
>> > ...
>> > no changes added to commit (use "git add" and/or "git commit -a")
>> >
>> > It detects the changes as renames however―which in this case isn't
>> > appropriate:
>> >
>> > [root@drew-northup ~]# etckeeper vcs status
>> > # On branch master
>> > # Changes to be committed:
>> > #   (use "git reset HEAD <file>..." to unstage)
>> > #
>> > #       renamed:    rc.d/rc2.d/K92iptables -> rc.d/rc2.d/S08iptables
>> > #       renamed:    rc.d/rc3.d/K92iptables -> rc.d/rc3.d/S08iptables
>> > #       renamed:    rc.d/rc4.d/K92iptables -> rc.d/rc4.d/S08iptables
>> > #...
>> 
>> Given that all of these six files have the same contents, I actually
>> am slightly impressed how well Git matched them up ;-).
>> 
>> But more seriously, why do you have rc.d/rc2.d/S08iptables untracked
>> in the working tree but in the index to be committed?
>
> Missing steps in the mail body: etckeeper vcs add <File> & etckeeper vcs
> rm <File> commands. I pared it back to the absolute minimum.
>
> Is that what you're asking about?

Yes. Without the "add" step, detecting the K92iptables that has been moved to an untracked S08iptables as rename looked like a magic (read: bug) to me, and that was why I asked.

Aren't K92iptables and S08iptables the same script with
  case "$1" in start) ... start thing ...;; stop) ... stop thing ...;; esac
in it?

On Debian, these S/K files appear directly under /etc without intermediate rc.d level, and they are symbolic links to real files in /etc/init.d/, so extrapolating from that knowledge and with a bit of imagination that some systems might keep copies of these files instead of linking to the same thing, I would actually find it desireable to call the move from K92iptables to S08iptables a rename, rather than reporting a removal and a addition of unrelated files.

Previous: Drew Northup
Message 5 of 5 in “rm and add, but not rename, of identical files”
  1. Drew NorthupOct 10, 2012
  2. Andreas SchwabOct 10, 2012
  3. Junio C HamanoOct 10, 2012
  4. Drew NorthupOct 11, 2012
  5. Junio C HamanoOct 11, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.