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

[PATCH v2 0/2] Retire git-parse-remote

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 12, 2020, 20:31 UTC
Message-ID
<20201112203155.3342586-1-gitster@pobox.com>
In-Reply-To
<xmqqwnyr4zv8.fsf@gitster.c.googlers.com>

This is based on Ævar's 5-patch series, which removed unused bits from git-parse-remote one by one, before finally moving the remnant to the only user to remove the file.

Earlier I suggested an alternative arrangement of the series to just lift what is still in use and then discard the rest without even splitting them out into separate commits---it is easy to see what's not used by grepping for names of the helper functions.

The only difference in the end result is that git-parse-remote.sh file itself is also removed.

Ævar Arnfjörð Bjarmason (2):
  parse-remote: move used code to git-submodule.sh
  parse-remote: remove this now-unused library
 .gitignore                         |   1 -
 Documentation/git-parse-remote.txt |  23 -------
 Makefile                           |   2 -
 command-list.txt                   |   1 -
 git-parse-remote.sh                | 101 -----------------------------
 git-submodule.sh                   |   8 ++-
 6 files changed, 7 insertions(+), 129 deletions(-)
 delete mode 100644 Documentation/git-parse-remote.txt
 delete mode 100644 git-parse-remote.sh
Range-diff against v1:
1:  f8c1396d68 < -:  ---------- parse-remote: remove unused GIT_DIR variable
2:  5f2dac99b8 < -:  ---------- parse-remote: remove long-dead rebase code
3:  871a40c7e0 < -:  ---------- parse-remote: remove long-dead git-pull.sh code
4:  17b0d43b65 ! 1:  8d8de925ea parse-remote: move used code to git-submodule.sh
    @@ Metadata
      ## Commit message ##
         parse-remote: move used code to git-submodule.sh
     
    -    Move the only code in git-parse-remote.sh that was actually used to
    -    git-submodule.sh.
    +    Move the get_default_remote () helper from git-parse-remote.sh to
    +    git-submodule.sh, as the latter is the only user.
     
    -    This leaves just a comment in git-parse-remote.sh for ease of review,
    -    a later commit will remove it and its build system configuration.
    +    There are two more helper functions, get_remote_merge_branch() and
    +    error_on_missing_default_upstream(), in the git-parse-remote shell
    +    function library, but they are not referenced by git-submodule.sh;
    +    stop dot-sourcing the git-parse-remote.
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
         Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
      ## git-parse-remote.sh ##
     @@
    - # This is a shell library to calculate the remote repository and
    - # upstream branch that should be pulled by "git pull" from the current
    - # branch.
    --
    + # this would fail in that case and would issue an error message.
    + GIT_DIR=$(git rev-parse -q --git-dir) || :;
    + 
     -get_default_remote () {
     -	curr_branch=$(git symbolic-ref -q HEAD)
     -	curr_branch="${curr_branch#refs/heads/}"
     -	origin=$(git config --get "branch.$curr_branch.remote")
     -	echo ${origin:-origin}
     -}
    +-
    + get_remote_merge_branch () {
    + 	case "$#" in
    + 	0|1)
     
      ## git-submodule.sh ##
    +@@ git-submodule.sh: USAGE="[--quiet] [--cached]
    + OPTIONS_SPEC=
    + SUBDIRECTORY_OK=Yes
    + . git-sh-setup
    +-. git-parse-remote
    + require_work_tree
    + wt_prefix=$(git rev-parse --show-prefix)
    + cd_to_toplevel
     @@ git-submodule.sh: is_tip_reachable () (
      	test -z "$rev"
      )
5:  1bda9e4479 ! 2:  a7520d32df parse-remote: remove this now-unused library
    @@ Metadata
      ## Commit message ##
         parse-remote: remove this now-unused library
     
    -    Completely remove the git-parse-remote shellscript library.
    -
    -    Since e9460a66e0 ("parse-remote: support default reflist in
    -    get_remote_merge_branch", 2009-06-12) when there were around 300 lines
    -    of code here used by various core code everything in it has become
    -    unsued, and that unused code was removed in preceding commits. Almost
    -    all of its previous functionality has now been rewritten in C.
    +    Since the previous step stopped dot-sourcing it from
    +    git-submodule.sh, nothing uses git-parse-remote, which
    +    still has two unused functions.  Remove the dead code
    +    together with the file itself and documentation.
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
         Signed-off-by: Junio C Hamano <gitster@pobox.com>
    @@ command-list.txt: git-p4                                  foreignscminterface
      git-prune                               ancillarymanipulators   complete
      git-prune-packed                        plumbingmanipulators
     
    - ## git-submodule.sh ##
    -@@ git-submodule.sh: USAGE="[--quiet] [--cached]
    - OPTIONS_SPEC=
    - SUBDIRECTORY_OK=Yes
    - . git-sh-setup
    --. git-parse-remote
    - require_work_tree
    - wt_prefix=$(git rev-parse --show-prefix)
    - cd_to_toplevel
    + ## git-parse-remote.sh (deleted) ##
    +@@
    +-# This is a shell library to calculate the remote repository and
    +-# upstream branch that should be pulled by "git pull" from the current
    +-# branch.
    +-
    +-# git-ls-remote could be called from outside a git managed repository;
    +-# this would fail in that case and would issue an error message.
    +-GIT_DIR=$(git rev-parse -q --git-dir) || :;
    +-
    +-get_remote_merge_branch () {
    +-	case "$#" in
    +-	0|1)
    +-	    origin="$1"
    +-	    default=$(get_default_remote)
    +-	    test -z "$origin" && origin=$default
    +-	    curr_branch=$(git symbolic-ref -q HEAD) &&
    +-	    [ "$origin" = "$default" ] &&
    +-	    echo $(git for-each-ref --format='%(upstream)' $curr_branch)
    +-	    ;;
    +-	*)
    +-	    repo=$1
    +-	    shift
    +-	    ref=$1
    +-	    # FIXME: It should return the tracking branch
    +-	    #        Currently only works with the default mapping
    +-	    case "$ref" in
    +-	    +*)
    +-		ref=$(expr "z$ref" : 'z+\(.*\)')
    +-		;;
    +-	    esac
    +-	    expr "z$ref" : 'z.*:' >/dev/null || ref="${ref}:"
    +-	    remote=$(expr "z$ref" : 'z\([^:]*\):')
    +-	    case "$remote" in
    +-	    '' | HEAD ) remote=HEAD ;;
    +-	    heads/*) remote=${remote#heads/} ;;
    +-	    refs/heads/*) remote=${remote#refs/heads/} ;;
    +-	    refs/* | tags/* | remotes/* ) remote=
    +-	    esac
    +-	    [ -n "$remote" ] && case "$repo" in
    +-		.)
    +-		    echo "refs/heads/$remote"
    +-		    ;;
    +-		*)
    +-		    echo "refs/remotes/$repo/$remote"
    +-		    ;;
    +-	    esac
    +-	esac
    +-}
    +-
    +-error_on_missing_default_upstream () {
    +-	cmd="$1"
    +-	op_type="$2"
    +-	op_prep="$3" # FIXME: op_prep is no longer used
    +-	example="$4"
    +-	branch_name=$(git symbolic-ref -q HEAD)
    +-	display_branch_name="${branch_name#refs/heads/}"
    +-	# If there's only one remote, use that in the suggestion
    +-	remote="$(gettext "<remote>")"
    +-	branch="$(gettext "<branch>")"
    +-	if test $(git remote | wc -l) = 1
    +-	then
    +-		remote=$(git remote)
    +-	fi
    +-
    +-	if test -z "$branch_name"
    +-	then
    +-		gettextln "You are not currently on a branch."
    +-	else
    +-		gettextln "There is no tracking information for the current branch."
    +-	fi
    +-	case "$op_type" in
    +-	rebase)
    +-		gettextln "Please specify which branch you want to rebase against."
    +-		;;
    +-	merge)
    +-		gettextln "Please specify which branch you want to merge with."
    +-		;;
    +-	*)
    +-		echo >&2 "BUG: unknown operation type: $op_type"
    +-		exit 1
    +-		;;
    +-	esac
    +-	eval_gettextln "See git-\${cmd}(1) for details."
    +-	echo
    +-	echo "    $example"
    +-	echo
    +-	if test -n "$branch_name"
    +-	then
    +-		gettextln "If you wish to set tracking information for this branch you can do so with:"
    +-		echo
    +-		echo "    git branch --set-upstream-to=$remote/$branch $display_branch_name"
    +-		echo
    +-	fi
    +-	exit 1
    +-}
-- 
2.29.2-442-ga30192deef
Previous: Junio C HamanoNext: Junio C Hamano
Message 24 of 62 in “Start retiring .git/remotes/ and .git/branches/ for good”
  1. 00/11 Start retiring .git/remotes/ and .git/branches/ for goodJohannes Schindelin, May 11, 2017
  2. 05/11 Revert "Revert "Don't create the $GIT_DIR/branches directory on init""Johannes Schindelin, May 11, 2017
  3. Stefan BellerMay 11, 2017
  4. 04/11 remote: warn loud and clear when .git/remotes/ is *still* usedJohannes Schindelin, May 11, 2017
  5. 01/11 git-parse-remote: fix highly misleading man pageJohannes Schindelin, May 11, 2017
  6. Stefan BellerMay 11, 2017
  7. Johannes SchindelinMay 11, 2017
  8. 0/5 Remove now-unused git-parse-remoteÆvar Arnfjörð Bjarmason, Nov 11, 2020
  9. Jeff KingNov 11, 2020
  10. Junio C HamanoNov 11, 2020
  11. Ævar Arnfjörð BjarmasonNov 12, 2020
  12. Jeff KingNov 12, 2020
  13. How do I "git fetch" with a custom <refspec> but a default remote?Ævar Arnfjörð Bjarmason, Nov 12, 2020
  14. Jeff KingNov 12, 2020
  15. Chris TorekNov 12, 2020
  16. Jeff KingNov 12, 2020
  17. Junio C HamanoNov 12, 2020
  18. Ævar Arnfjörð BjarmasonNov 14, 2020
  19. 1/5 parse-remote: remove unused GIT_DIR variableÆvar Arnfjörð Bjarmason, Nov 11, 2020
  20. 2/5 parse-remote: remove long-dead rebase codeÆvar Arnfjörð Bjarmason, Nov 11, 2020
  21. 4/5 parse-remote: move used code to git-submodule.shÆvar Arnfjörð Bjarmason, Nov 11, 2020
  22. 5/5 parse-remote: remove this now-unused libraryÆvar Arnfjörð Bjarmason, Nov 11, 2020
  23. Junio C HamanoNov 11, 2020
  24. 0/2 Retire git-parse-remoteJunio C Hamano, Nov 12, 2020
  25. 1/2 parse-remote: move used code to git-submodule.shJunio C Hamano, Nov 12, 2020
  26. 2/2 parse-remote: remove this now-unused libraryJunio C Hamano, Nov 12, 2020
  27. Jeff KingNov 12, 2020
  28. Junio C HamanoNov 12, 2020
  29. Ævar Arnfjörð BjarmasonNov 13, 2020
  30. 0/3 submodule sh->C & retire parse-remoteÆvar Arnfjörð Bjarmason, Nov 14, 2020
  31. 1/3 submodule: use "fetch" logic instead of custom remote discoveryÆvar Arnfjörð Bjarmason, Nov 14, 2020
  32. Junio C HamanoNov 16, 2020
  33. 3/3 parse-remote: remove this now-unused libraryÆvar Arnfjörð Bjarmason, Nov 14, 2020
  34. Junio C HamanoNov 16, 2020
  35. Ævar Arnfjörð BjarmasonNov 17, 2020
  36. 2/3 submodule: remove sh function in favor of helperÆvar Arnfjörð Bjarmason, Nov 14, 2020
  37. 3/5 parse-remote: remove long-dead git-pull.sh codeÆvar Arnfjörð Bjarmason, Nov 11, 2020
  38. 03/11 remote: warn loud and clear when .git/branches/ is *still* usedJohannes Schindelin, May 11, 2017
  39. 09/11 PREVIEW: t5515: remove .git/remotes/ and .git/branches/ testsJohannes Schindelin, May 11, 2017
  40. 02/11 Documentation: really deprecate .git/remotes/ and .git/branches/Johannes Schindelin, May 11, 2017
  41. 10/11 PREVIEW: t0060: stop testing support for .git/remotes/ and .git/branches/Johannes Schindelin, May 11, 2017
  42. 11/11 PREVIEW: remove support for .git/remotes/ and .git/branches/Johannes Schindelin, May 11, 2017
  43. Stefan BellerMay 11, 2017
  44. Johannes SchindelinMay 11, 2017
  45. 06/11 PREVIEW: t5510: convert .git/remotes/ test to use a regular remoteJohannes Schindelin, May 11, 2017
  46. 07/11 PREVIEW: t5516: stop testing .git/branches/ functionalityJohannes Schindelin, May 11, 2017
  47. 08/11 PREVIEW: remote: remove support for migrating ancient remotesJohannes Schindelin, May 11, 2017
  48. Junio C HamanoMay 12, 2017
  49. Johannes SchindelinMay 12, 2017
  50. Junio C HamanoMay 16, 2017
  51. Ævar Arnfjörð BjarmasonMay 16, 2017
  52. Junio C HamanoMay 16, 2017
  53. Ævar Arnfjörð BjarmasonMay 16, 2017
  54. Junio C HamanoMay 17, 2017
  55. Junio C HamanoMay 12, 2017
  56. Johannes SchindelinMay 12, 2017
  57. Jonathan NiederMay 12, 2017
  58. Junio C HamanoMay 13, 2017
  59. Junio C HamanoMay 12, 2017
  60. Johannes SchindelinMay 15, 2017
  61. Jeff KingMay 12, 2017
  62. Johannes SchindelinMay 12, 2017

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.