Re: [PATCH 5/7] git mv: Support moving submodules

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Wednesday, July 16, 2008 - 7:37 pm

Petr Baudis <pasky@suse.cz> writes:


I do not think use of path_list->util is particularly bad.  It is a data
structure to store a bag of random pointers that can be indexed with
string keys, which is exactly what you are doing here.


This one certainly is ugly beyond words.

By the way, why is it even necessary to rehash the contents when you run
"mv"?

IOW,

	$ >foo
        $ git add foo
        $ echo 1 >foo
        $ git mv foo bar

makes "foo" disappear from the index and adds "bar", but it makes the
local change added to the index at the same time.

	Side note. It actually is a lot worse than that.  When you move
	something to another existing entry, the code does not even add
	the object name of moved entry recorded in the index, nor rehashes
	the moved file.  This is totally inconsistent!

I personally think these buggy behaviours you are trying to inherit are
making this patch more complex than necessary.  Perhaps this needs to be
fixed up even further (you did some fix with the first patch) before
adding new features?  For example, I think it is a bug that the
"overwrite" codepath does not work with symlinks.

But let's assume that we do not want to "fix" any of these existing
(mis)behaviour, because doing so would change the semantics.

There are a few cases:

 (1) gitlink exists and so is directory but no repository (i.e. the user is
     not interested);

 (2) gitlink exists and there is a repository.  Its HEAD matches what
     gitlink records;

 (3) gitlink exists and there is a repository.  Its HEAD does not match what
     gitlink records;

The (mis)behaviour that automatically adds moved files to the index we saw
earlier suggests that in case (3) you would want to update the gitlink in
the index with whatever HEAD the submodule repository has to be
consistent.

So instead of adding a index_path_src_sha1 hack like that, how about

 * When you see ce_is_gitlink(j), you keep the original gitlink object
   name.  That is very good in order to preserve it for not just (1) but
   also for (3) once we decide to fix this "auto adding" misbehaviour in
   the later round.  But you do not have to do this for case (2) if you
   are going to rehash anyway, don't you?

   So when you see ce_is_gitlink(j), you check if it has repository and
   HEAD, and record the path_list->util only when it is case (1).

 * Then, only for case (1), you do not call add_file_to_cache() -- because
   you know you do not have anything you can rehash; instead, factor out
   the codepath "git-update-index --cacheinfo" uses and call that.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH 0/7] Submodule support in git mv, git rm, Petr Baudis, (Wed Jul 16, 12:11 pm)
[PATCH 1/7] git-mv: Remove dead code branch, Petr Baudis, (Wed Jul 16, 12:11 pm)
[PATCH 5/7] git mv: Support moving submodules, Petr Baudis, (Wed Jul 16, 12:11 pm)
[PATCH 6/7] git rm: Support for removing submodules, Petr Baudis, (Wed Jul 16, 12:11 pm)
[PATCH 7/7] t7403: Submodule git mv, git rm testsuite, Petr Baudis, (Wed Jul 16, 12:11 pm)
Re: [PATCH 6/7] git rm: Support for removing submodules, Johannes Schindelin, (Wed Jul 16, 3:41 pm)
Re: [PATCH 5/7] git mv: Support moving submodules, Junio C Hamano, (Wed Jul 16, 7:37 pm)
Re: [PATCH 6/7] git rm: Support for removing submodules, Johannes Schindelin, (Thu Jul 17, 5:59 am)
Re: [PATCH 5/7] git mv: Support moving submodules, Petr Baudis, (Thu Jul 17, 6:06 am)
[PATCH] git-mv: Keep moved index entries inact, Petr Baudis, (Thu Jul 17, 3:31 pm)
[PATCH] git mv: Support moving submodules, Petr Baudis, (Thu Jul 17, 3:34 pm)
Re: [PATCH] git-mv: Keep moved index entries inact, Junio C Hamano, (Sat Jul 19, 4:54 pm)
Re: [PATCH] git-mv: Keep moved index entries inact, Petr Baudis, (Sun Jul 20, 5:23 pm)
[PATCHv2] git-mv: Keep moved index entries inact, Petr Baudis, (Sun Jul 20, 5:25 pm)
Re: [PATCH] git-mv: Keep moved index entries inact, Johannes Schindelin, (Sun Jul 20, 6:20 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Junio C Hamano, (Sun Jul 20, 9:36 pm)
Re: [PATCH] git-mv: Keep moved index entries inact, Petr Baudis, (Mon Jul 21, 12:18 am)
Re: [PATCH] git-mv: Keep moved index entries inact, Junio C Hamano, (Mon Jul 21, 12:38 am)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Junio C Hamano, (Fri Jul 25, 11:46 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Petr Baudis, (Sun Jul 27, 6:41 am)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Johannes Schindelin, (Mon Jul 28, 8:06 am)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Johannes Schindelin, (Mon Jul 28, 8:14 am)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Johannes Schindelin, (Mon Jul 28, 11:24 am)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Junio C Hamano, (Mon Jul 28, 12:19 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Johannes Schindelin, (Mon Jul 28, 4:41 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Johannes Schindelin, (Mon Jul 28, 4:55 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Petr Baudis, (Mon Jul 28, 5:17 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Junio C Hamano, (Mon Jul 28, 5:46 pm)
Re: [PATCHv2] git-mv: Keep moved index entries inact, Junio C Hamano, (Mon Jul 28, 10:23 pm)
Not going beyond symbolic links, Junio C Hamano, (Mon Aug 4, 12:49 am)
Re: Not going beyond symbolic links, Linus Torvalds, (Mon Aug 4, 5:21 pm)
Re: Not going beyond symbolic links, Junio C Hamano, (Mon Aug 4, 5:54 pm)
Re: Not going beyond symbolic links, Linus Torvalds, (Mon Aug 4, 6:43 pm)
Re: Not going beyond symbolic links, Johannes Schindelin, (Mon Aug 4, 6:59 pm)
Re: Not going beyond symbolic links, Linus Torvalds, (Mon Aug 4, 7:28 pm)
Re: Not going beyond symbolic links, Junio C Hamano, (Mon Aug 4, 9:44 pm)
Re: Not going beyond symbolic links, Johannes Schindelin, (Tue Aug 5, 4:23 am)
Re: Not going beyond symbolic links, Junio C Hamano, (Wed Aug 6, 11:52 pm)
Re: Not going beyond symbolic links, Junio C Hamano, (Fri Aug 8, 1:55 pm)
Re: Not going beyond symbolic links, Linus Torvalds, (Fri Aug 8, 4:45 pm)