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

Re: [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees

From
Paul Campbell <pcampbell@kemitix.net>
Date
Mar 24, 2013, 20:17 UTC
Message-ID
<CALeLG_nEuH6BOydUPTnDb5CrF=+5tipreHCAooxNnYW2eyVHLQ@mail.gmail.com>
In-Reply-To
<7vsj42bove.fsf@alter.siamese.dyndns.org>
On Mon, Mar 11, 2013 at 3:24 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 44 quoted lines
> Paul Campbell <pcampbell@kemitix.net> writes:
>
>> From: Matt Hoffman <matt.hoffman@quantumretail.com>
>>
>> The repository and branch of a subtree added with the add command is
>> stored in the .gittrees file.
>>
>> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
>> ---
>>  contrib/subtree/git-subtree.sh | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index caf4988..7b70251 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -528,6 +528,14 @@ cmd_add_repository()
>>       revs=FETCH_HEAD
>>       set -- $revs
>>       cmd_add_commit "$@"
>> +
>> +  # now add it to our list of repos
>> +  git config -f .gittrees --unset subtree.$dir.url
>> +  git config -f .gittrees --add subtree.$dir.url $repository
>> +  git config -f .gittrees --unset subtree.$dir.path
>> +  git config -f .gittrees --add subtree.$dir.path $dir
>> +  git config -f .gittrees --unset subtree.$dir.branch
>> +  git config -f .gittrees --add subtree.$dir.branch $refspec
>
> Existing code in the function this touches seem to be written
> carefully to allow $IFS whitespace in $dir, but this change butchers
> it, it seems.
>
> Also, where does $refspec come from?  When this is called from
> cmd_add_repository(), there is an assignment to the variable, but it
> is not all clear.  As git-subtree declares it won't work with
> anything but bash, I think things like this should take advantage of
> being written for bash by using "local" and passing arguments
> explicitly instead of relying on global variables, which POSIX shell
> scripts cannot afford to do but bash scripts can.
>
>>  }
>>
>>  cmd_add_commit()

$refspec gets assigned in the third line of the function. The function has only one caller in cmd_add() inside an if clause that requires there be two parameters.

Personally I'd rather move git-subtree to be more portable and less dependant on bash. I've sent some patches earlier to remove that dependancy. As far as I could see there wasn't really anything that was bash-only.

Reroll of this patch coming shortly allowing for $IFS whitespace.
-- 
Paul [W] Campbell
Previous: Junio C HamanoNext: Paul Campbell
Message 8 of 33 in “contrib/subtree: Collected updates”
  1. 00/23 contrib/subtree: Collected updatesPaul Campbell, Mar 10, 2013
  2. 01/23 contrib/subtree: Fix typo (s/incldued/included/)Paul Campbell, Mar 10, 2013
  3. 02/23 contrib/subtree: Add command from-submodulePaul Campbell, Mar 10, 2013
  4. Junio C HamanoMar 11, 2013
  5. contrib/subtree: Add command from-submodulePaul Campbell, Mar 24, 2013
  6. 03/23 contrib/subtree: Teach add to store repository & branch in .gittreesPaul Campbell, Mar 10, 2013
  7. Junio C HamanoMar 11, 2013
  8. Paul CampbellMar 24, 2013
  9. contrib/subtree: Teach add to store repository & branch in .gittreesPaul Campbell, Mar 24, 2013
  10. 04/23 contrib/subtree: Teach push and pull to use .gittrees for defaultsPaul Campbell, Mar 10, 2013
  11. Junio C HamanoMar 11, 2013
  12. Paul CampbellMar 24, 2013
  13. 05/23 contrib/subtree: Add commands pull_all and push_allPaul Campbell, Mar 10, 2013
  14. Junio C HamanoMar 11, 2013
  15. Paul CampbellMar 11, 2013
  16. 06/23 contrib/subtree: Rename commands push_all/pull_all to push-all/pull-allPaul Campbell, Mar 10, 2013
  17. 07/23 contrib/subtree: Teach push and pull to use .gittrees if neededPaul Campbell, Mar 10, 2013
  18. 08/23 contrib/subtree: Replace invisible carriage return with a visible \rPaul Campbell, Mar 10, 2013
  19. 09/23 contrib/subtree: Teach push to abort if split failsPaul Campbell, Mar 10, 2013
  20. 10/23 contrib/subtree: Add command diffPaul Campbell, Mar 10, 2013
  21. 11/23 contrib/subtree: Add command listPaul Campbell, Mar 10, 2013
  22. 12/23 contrib/subtree: Add command prunePaul Campbell, Mar 10, 2013
  23. 13/23 contrib/subtree: Add prune command to OPTS_SPECPaul Campbell, Mar 10, 2013
  24. 14/23 contrib/subtree: Remove trailing slash from prefix parameterPaul Campbell, Mar 10, 2013
  25. 15/23 contrib/subtree: Teach from-submodule to add new subtree to .gittreesPaul Campbell, Mar 10, 2013
  26. 16/23 contrib/subtree: Document pull-all and push-allPaul Campbell, Mar 10, 2013
  27. 17/23 contrib/subtree: Document from-submodule and prune commandsPaul Campbell, Mar 10, 2013
  28. 18/23 contrib/subtree: Add missing commands to SYNOPSISPaul Campbell, Mar 10, 2013
  29. 19/23 contrib/subtree: Document list commandPaul Campbell, Mar 10, 2013
  30. 20/23 contrib/subtree: Teach push to use --force optionPaul Campbell, Mar 10, 2013
  31. 21/23 contrib/subtree: Convert spaces to tabs and remove some trailing whitespacePaul Campbell, Mar 10, 2013
  32. 22/23 contrib/subtree: Parameters repository/branch for push/pull are optionalPaul Campbell, Mar 10, 2013
  33. 23/23 contrib/subtree: Fix order of case switches so default case is lastPaul Campbell, Mar 10, 2013

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.