git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Manish Goregaokar via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Manish Goregaokar <manishsmail@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 0/1] submodule: Fix 'submodule status' when called from a subdirectory
Date: Sun, 24 Nov 2019 08:01:12 +0000	[thread overview]
Message-ID: <pull.472.v2.git.1574582473.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.472.git.1574490521.gitgitgadget@gmail.com>

Updated to include a test and a more standard commit message.

Manish Goregaokar (1):
  submodule: fix 'submodule status' when called from a subdirectory

 builtin/submodule--helper.c |  3 ++-
 t/t7400-submodule-basic.sh  | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)


base-commit: 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-472%2FManishearth%2Fsubdir-status-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-472/Manishearth/subdir-status-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/472

Range-diff vs v1:

 1:  2004f4aaa9 ! 1:  e4c932bd09 submodule: Fix 'submodule status' when called from a subdirectory
     @@ -1,18 +1,18 @@
      Author: Manish Goregaokar <manishsmail@gmail.com>
      
     -    submodule: Fix 'submodule status' when called from a subdirectory
     +    submodule: fix 'submodule status' when called from a subdirectory
      
     -    Previously, when calling `git submodule status` while in a
     -    subdirectory, it was incorrectly not detecting modified submodules and
     -    thus reporting that all of the submodules were unchanged.
     +    When calling `git submodule status` while in a subdirectory, we are
     +    incorrectly not detecting modified submodules and
     +    thus reporting that all of the submodules are unchanged.
      
     -    This was because the submodule helper was calling `diff-index` with the
     -    submodule path assuming the path was relative to the current prefix
     +    This is because the submodule helper is calling `diff-index` with the
     +    submodule path assuming the path is relative to the current prefix
          directory, however the submodule path used is actually relative to the root.
      
     -    This fixes the bug by setting the `prefix` to NULL when running
     -    `diff-index` from the helper, so that it correctly interprets the path
     -    as relative to the repository root.
     +    Always pass NULL as the `prefix` when running diff-files on the
     +    submodule, to make sure the submodule's path is interpreted as relative
     +    to the superproject's repository root.
      
          Signed-off-by: Manish Goregaokar <manishsmail@gmail.com>
      
     @@ -24,10 +24,38 @@
       
       	git_config(git_diff_basic_config, NULL);
      -	repo_init_revisions(the_repository, &rev, prefix);
     -+	/*
     -+	 * prefix is NULL since path is an absolute path
     -+	 */
     ++
      +	repo_init_revisions(the_repository, &rev, NULL);
       	rev.abbrev = 0;
       	diff_files_args.argc = setup_revisions(diff_files_args.argc,
       					       diff_files_args.argv,
     +
     + diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
     + --- a/t/t7400-submodule-basic.sh
     + +++ b/t/t7400-submodule-basic.sh
     +@@
     + 	test_line_count = 1 lines
     + '
     + 
     ++test_expect_success 'status from subdirectory should have the same SHA1' '
     ++	test_when_finished "rmdir addtest/subdir" &&
     ++	(
     ++		cd addtest &&
     ++		git status > /tmp/foo &&
     ++		git submodule status | awk "{print \$1}" >expected &&
     ++		mkdir subdir &&
     ++		cd subdir &&
     ++		git submodule status | awk "{print \$1}" >../actual &&
     ++		test_cmp ../expected ../actual &&
     ++		git -C ../submod checkout @^ &&
     ++		git submodule status | awk "{print \$1}" >../actual2 &&
     ++		cd .. &&
     ++		git submodule status | awk "{print \$1}" >expected2 &&
     ++		test_cmp actual2 expected2 &&
     ++		test_must_fail test_cmp actual actual2
     ++	)
     ++'
     ++
     + test_expect_success 'setup - fetch commit name from submodule' '
     + 	rev1=$(cd .subrepo && git rev-parse HEAD) &&
     + 	printf "rev1: %s\n" "$rev1" &&

-- 
gitgitgadget

  parent reply	other threads:[~2019-11-24  8:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23  6:28 [PATCH 0/1] submodule: Fix 'submodule status' when called from a subdirectory Manish Goregaokar via GitGitGadget
2019-11-23  6:28 ` [PATCH 1/1] " Manish Goregaokar via GitGitGadget
2019-11-24  5:17   ` Junio C Hamano
2019-11-24  8:01 ` Manish Goregaokar via GitGitGadget [this message]
2019-11-24  8:01   ` [PATCH v2 1/1] submodule: fix " Manish Goregaokar via GitGitGadget
2019-11-25  1:56     ` Junio C Hamano
2019-11-25  4:08       ` Manish Goregaokar
2019-11-25  4:15   ` [PATCH v3 0/1] submodule: Fix " Manish Goregaokar via GitGitGadget
2019-11-25  4:15     ` [PATCH v3 1/1] submodule: fix " Manish Goregaokar via GitGitGadget
2019-11-25  4:51       ` Junio C Hamano
2019-11-25  6:32         ` Manish Goregaokar

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=pull.472.v2.git.1574582473.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=manishsmail@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).