git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ping Yin <pkufranky@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/4] Fix diff regression for submodules not checked out
Date: Fri, 02 May 2008 15:23:01 -0700	[thread overview]
Message-ID: <7vfxt0wdkq.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1209735336-4690-4-git-send-email-pkufranky@gmail.com> (Ping Yin's message of "Fri, 2 May 2008 21:35:35 +0800")

Ping Yin <pkufranky@gmail.com> writes:

> This regression is introduced by f58dbf23c3, which calls
> check_work_tree_entity in run_diff_files.  While check_work_tree_entity
> treats submodule not checked out as non stagable which causes that
> diff-files shows these submodules as deleted.

>  int run_diff_files(struct rev_info *revs, unsigned int option)
> @@ -403,7 +407,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
>  			       sizeof(struct combine_diff_parent)*5);
>  
>  			changed = check_work_tree_entity(ce, &st, symcache);
> -			if (!changed)
> +			if (changed != ENT_INEXISTENT)
>  				dpath->mode = ce_mode_from_stat(ce, st.st_mode);

>  			else {
>  				if (changed < 0) {
> @@ -467,7 +471,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
>  			continue;
>  
>  		changed = check_work_tree_entity(ce, &st, symcache);
> -		if (changed) {
> +		if (changed == ENT_INEXISTENT) {
>  			if (changed < 0) {
>  				perror(ce->name);
>  				continue;
> @@ -527,7 +531,7 @@ static int get_stat_data(struct cache_entry *ce,
>  		changed = check_work_tree_entity(ce, &st, cbdata->symcache);
>  		if (changed < 0)
>  			return -1;
> -		else if (changed) {
> +		else if (changed == ENT_INEXISTENT) {
>  			if (match_missing) {
>  				*sha1p = sha1;
>  				*modep = mode;

Earier I said we may have to teach the Porcelain layer (status, diff) to
equate a submodule that is not checked out and a submodule that is not
modified while keeping low-level plumbing (diff-files and diff-index)
still aware that the submodule is missing from the work tree, but that was
because I incorrectly thought there are only two cases (either the
submodule is fully checked out or the submodule directory itself does not
even exist) and treating the latter the same as an unmodified case would
mean there won't be an easy way to remove the submodule from the
superproject for Porcelains that are written in terms of diff-files and
diff-index.

But that was a faulty thinking on my part (heh, why didn't anybody correct
me?).  Actually, there are three cases:

 - submodule directory exists and it is a full fledged repository.  It may
   or may not be modified, but we can tell by looking at its .git/HEAD.

 - submodule directory exists but there is nothing there (no "init" nor
   "update" was done, just an empty directory checked out).  This is how a
   superproject with a submodule is checked out by default.

 - submodule directory itself does not even exist.

The second case is "not checked out -- treat me as unmodified", and the
third case is "the user does not want the submodule there", and the latter
is still reported as "removed".  That is exactly what your patch does.

I like it.

By the way, "inexistent" is a word, but somehow it sounds quite awkward.
Perhaps one of NONEXISTENT (more common), REMOVED (run_diff_files() takes
a SILENT_ON_REMOVED option) or or MISSING (update-index --refresh takes an
IGNORE_MISSING option) is better?  I dunno.

  parent reply	other threads:[~2008-05-02 22:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22 11:01 [regression?] "git status -a" reports modified for empty submodule directory Ping Yin
2008-04-22 11:04 ` Ping Yin
2008-04-22 12:15 ` Johannes Sixt
2008-04-22 12:39   ` Ping Yin
2008-04-22 12:46     ` Johannes Sixt
2008-04-22 18:00     ` Roman Shaposhnik
2008-04-29 15:31 ` Ping Yin
2008-04-29 16:07   ` [PATCH 0/2] Add tests for submodule with empty directory Ping Yin
2008-04-29 16:07     ` [PATCH 1/2] t4027: test diff " Ping Yin
2008-04-29 16:07       ` [PATCH 2/2] Add t7506 to test submodule related functions for git-status Ping Yin
2008-04-29 21:40   ` [regression?] "git status -a" reports modified for empty submodule directory Junio C Hamano
2008-04-30  6:39     ` Johannes Sixt
2008-04-30  7:29       ` Junio C Hamano
2008-04-30 15:56         ` Ping Yin
2008-05-02 13:35           ` [PATCH 0/4] Fix regression for unchecked out submodules Ping Yin
2008-05-02 13:35             ` [PATCH 1/4] t4027: test diff for submodule with empty directory Ping Yin
2008-05-02 13:35               ` [PATCH 2/4] Add t7506 to test submodule related functions for git-status Ping Yin
2008-05-02 13:35                 ` [PATCH 3/4] Fix diff regression for submodules not checked out Ping Yin
2008-05-02 13:35                   ` [PATCH 4/4] Fix ie_match_stat for non-checked-out submodule Ping Yin
2008-05-02 21:57                     ` Junio C Hamano
2008-05-02 23:34                       ` Ping Yin
2008-05-02 22:23                   ` Junio C Hamano [this message]
2008-05-02 23:55                     ` [PATCH 3/4] Fix diff regression for submodules not checked out Ping Yin
2008-05-03  0:07                     ` [PATCH] Rename ENT_INEXISTENT to ENT_NONEXISTENT Ping Yin
2008-05-03 12:36                     ` [PATCH 3/4] Fix diff regression for submodules not checked out Johannes Schindelin
2008-05-03 16:59                       ` Junio C Hamano
2008-05-04  6:45                     ` Junio C Hamano
2008-05-04  7:10                       ` Ping Yin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vfxt0wdkq.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pkufranky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).