{"thread":{"id":"23757","subject":"[PATCH] ls-remote: print URL when no repo is specified","startedAt":"2010-05-09T14:42:20Z","lastAt":"2010-05-20T13:27:29Z","messageCount":12,"participants":["Tay Ray Chuan","Jonathan Nieder","Junio C Hamano","Geert Bosch","Sverre Rabbelier"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"141314","messageId":"1273416140-5044-1-git-send-email-rctay89@gmail.com","threadId":"23757","inReplyTo":null,"subject":"[PATCH] ls-remote: print URL when no repo is specified","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-05-09T14:42:20Z","receivedAt":"2010-05-09T14:42:20Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"After 9c00de5 (ls-remote: fall-back to default remotes when no remote\nspecified), when no repository is specified, ls-remote may use\nthe URL/remote in the config \"branch.<name>.remote\" or the remote\n\"origin\"; it may not be immediately obvious to the user which was used.\n\nIn such cases, print a simple \"From <URL>\" line to indicate which\nrepository was used. This message is similar to git-fetch's, and is\nprinted to stderr to avoid breaking existing scripts that depend on\nls-remote's output behaviour.\n\nIt can also be disabled with -q/--quiet.\n\nModify tests related to falling back on default remotes to check for\nthis as well, and add a test to check for suppression of the message.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\n  This is a logical follow-up to the \"optional repo\" form of ls-remote\n  feature. Myself, I was using the \"no-repo\" form of ls-remote and\n  sometimes wondered where it was listing remotes from.\n\n  Johnathan, do you think the tests involved might have any cross-\n  platform issues?\n\n builtin/ls-remote.c  |   10 +++++++++-\n t/t5512-ls-remote.sh |   19 +++++++++++++++----\n 2 files changed, 24 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 8ee91eb..34480cf 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,7 @@\n\n static const char ls_remote_usage[] =\n \"git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\\n\"\n-\"                     [<repository> [<refs>...]]\";\n+\"                     [-q|--quiet] [<repository> [<refs>...]]\";\n\n /*\n  * Is there one among the list of patterns that match the tail part\n@@ -34,6 +34,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tconst char *dest = NULL;\n \tint nongit;\n \tunsigned flags = 0;\n+\tint quiet = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n\n@@ -67,6 +68,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t\tflags |= REF_NORMAL;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(\"--quiet\", arg) || !strcmp(\"-q\", arg)) {\n+\t\t\t\tquiet = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tusage(ls_remote_usage);\n \t\t}\n \t\tdest = arg;\n@@ -99,6 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tref = transport_get_remote_refs(transport);\n \tif (transport_disconnect(transport))\n \t\treturn 1;\n+\n+\tif (!dest && !quiet)\n+\t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n \tfor ( ; ref; ref = ref->next) {\n \t\tif (!check_ref_type(ref, flags))\n \t\t\tcontinue;\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 3cf1b3d..8508df8 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -57,12 +57,21 @@ test_expect_success 'dies when no remote specified and no default remotes found'\n\n test_expect_success 'use \"origin\" when no remote specified' '\n\n-\tgit remote add origin \"$(pwd)/.git\" &&\n-\tgit ls-remote >actual &&\n+\tURL=\"$(pwd)/.git\" &&\n+\tgit remote add origin \"$URL\" &&\n+\tgit ls-remote 2>actual_err >actual &&\n+\tgrep \"From $URL\" actual_err &&\n \ttest_cmp expected.all actual\n\n '\n\n+test_expect_success 'suppress \"From <url>\" with -q' '\n+\n+\tgit ls-remote -q 2>actual_err &&\n+\ttest_must_fail grep \"From $URL\" actual_err\n+\n+'\n+\n test_expect_success 'use branch.<name>.remote if possible' '\n\n \t#\n@@ -78,10 +87,12 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \t\tgit show-ref\t| sed -e \"s/ /\t/\"\n \t) >exp &&\n\n-\tgit remote add other other.git &&\n+\tURL=\"other.git\" &&\n+\tgit remote add other $URL &&\n \tgit config branch.master.remote other &&\n\n-\tgit ls-remote >actual &&\n+\tgit ls-remote 2>actual_err >actual &&\n+\tgrep \"From $URL\" actual_err &&\n \ttest_cmp exp actual\n\n '\n--\n1.7.1.189.g07419\n"},{"id":"141336","messageId":"20100509220122.GA2098@progeny.tock","threadId":"23757","inReplyTo":"1273416140-5044-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH] ls-remote: print URL when no repo is specified","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-09T22:01:23Z","receivedAt":"2010-05-09T22:01:23Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Tay Ray Chuan wrote:\n\n> when no repository is specified, ls-remote may use\n> the URL/remote in the config \"branch.<name>.remote\" or the remote\n> \"origin\"\n[...]\n> In such cases, print a simple \"From <URL>\" line to indicate which\n> repository was used. This message is similar to git-fetch's\n\nMakes sense.  The code and tests look sane.\n\nTesting on Linux and Msysgit does not reveal any problems, either.\n\nThanks,\nJonathan\n"},{"id":"141486","messageId":"1273598423-3156-1-git-send-email-rctay89@gmail.com","threadId":"23757","inReplyTo":"1273416140-5044-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-05-11T17:20:23Z","receivedAt":"2010-05-11T17:20:23Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"After 9c00de5 (ls-remote: fall-back to default remotes when no remote\nspecified), when no repository is specified, ls-remote may use\nthe URL/remote in the config \"branch.<name>.remote\" or the remote\n\"origin\"; it may not be immediately obvious to the user which was used.\n\nIn such cases, print a simple \"From <URL>\" line to indicate which\nrepository was used. This message is similar to git-fetch's, and is\nprinted to stderr to avoid breaking existing scripts that depend on\nls-remote's output behaviour.\n\nIt can also be disabled with -q/--quiet.\n\nModify tests related to falling back on default remotes to check for\nthis as well, and add a test to check for suppression of the message.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\n  The sole difference from the previous patch is the use of test_cmp\n  instead of grep in the tests.\n\n builtin/ls-remote.c  |   10 +++++++++-\n t/t5512-ls-remote.sh |   24 ++++++++++++++++++++----\n 2 files changed, 29 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 8ee91eb..34480cf 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,7 @@\n\n static const char ls_remote_usage[] =\n \"git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\\n\"\n-\"                     [<repository> [<refs>...]]\";\n+\"                     [-q|--quiet] [<repository> [<refs>...]]\";\n\n /*\n  * Is there one among the list of patterns that match the tail part\n@@ -34,6 +34,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tconst char *dest = NULL;\n \tint nongit;\n \tunsigned flags = 0;\n+\tint quiet = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n\n@@ -67,6 +68,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t\tflags |= REF_NORMAL;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(\"--quiet\", arg) || !strcmp(\"-q\", arg)) {\n+\t\t\t\tquiet = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tusage(ls_remote_usage);\n \t\t}\n \t\tdest = arg;\n@@ -99,6 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tref = transport_get_remote_refs(transport);\n \tif (transport_disconnect(transport))\n \t\treturn 1;\n+\n+\tif (!dest && !quiet)\n+\t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n \tfor ( ; ref; ref = ref->next) {\n \t\tif (!check_ref_type(ref, flags))\n \t\t\tcontinue;\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 3cf1b3d..d191235 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -57,12 +57,24 @@ test_expect_success 'dies when no remote specified and no default remotes found'\n\n test_expect_success 'use \"origin\" when no remote specified' '\n\n-\tgit remote add origin \"$(pwd)/.git\" &&\n-\tgit ls-remote >actual &&\n+\tURL=\"$(pwd)/.git\" &&\n+\techo \"From $URL\" >exp_err &&\n+\n+\tgit remote add origin \"$URL\" &&\n+\tgit ls-remote 2>actual_err >actual &&\n+\n+\ttest_cmp exp_err actual_err &&\n \ttest_cmp expected.all actual\n\n '\n\n+test_expect_success 'suppress \"From <url>\" with -q' '\n+\n+\tgit ls-remote -q 2>actual_err &&\n+\ttest_must_fail test_cmp exp_err actual_err\n+\n+'\n+\n test_expect_success 'use branch.<name>.remote if possible' '\n\n \t#\n@@ -78,10 +90,14 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \t\tgit show-ref\t| sed -e \"s/ /\t/\"\n \t) >exp &&\n\n-\tgit remote add other other.git &&\n+\tURL=\"other.git\" &&\n+\techo \"From $URL\" >exp_err &&\n+\n+\tgit remote add other $URL &&\n \tgit config branch.master.remote other &&\n\n-\tgit ls-remote >actual &&\n+\tgit ls-remote 2>actual_err >actual &&\n+\ttest_cmp exp_err actual_err &&\n \ttest_cmp exp actual\n\n '\n--\n1.7.1.189.g07419\n"},{"id":"141504","messageId":"7veihh8y8b.fsf@alter.siamese.dyndns.org","threadId":"23757","inReplyTo":"1273598423-3156-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-12T05:50:44Z","receivedAt":"2010-05-12T05:50:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> After 9c00de5 (ls-remote: fall-back to default remotes when no remote\n> specified), when no repository is specified, ls-remote may use\n> the URL/remote in the config \"branch.<name>.remote\" or the remote\n> \"origin\"; it may not be immediately obvious to the user which was used.\n\nI cannot convince myself that this is a good change, as I've always\nthought \"ls-remote\" output as something people want to let their scripts\nread and parse.  9c00de5 may have given an enhancement to these scripts in\nthe sense that they can now respond to an empty input from the end user,\nbut this patch forces them to change the way they parse the output from\nthe command.\n\nI also think this patch is solving a wrong problem.\n\nWhen an end user does not know which remote ls-remote would be talking to\nby default, what else does he *not* know?  Probably which remote \"pull\"\nwould be fetching from and what branch it would be merging with?  Doesn't\nhe have a better command to use to learn that information to reorient\nhimself when he is lost that way?\n"},{"id":"141624","messageId":"AANLkTinxm8hwX53LE9_7rDPoKs9UnGAyFFfVcoh-WGxE@mail.gmail.com","threadId":"23757","inReplyTo":"7veihh8y8b.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-05-14T03:07:41Z","receivedAt":"2010-05-14T03:07:41Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Wed, May 12, 2010 at 1:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Tay Ray Chuan <rctay89@gmail.com> writes:\n>\n>> After 9c00de5 (ls-remote: fall-back to default remotes when no remote\n>> specified), when no repository is specified, ls-remote may use\n>> the URL/remote in the config \"branch.<name>.remote\" or the remote\n>> \"origin\"; it may not be immediately obvious to the user which was used.\n>\n> I cannot convince myself that this is a good change, as I've always\n> thought \"ls-remote\" output as something people want to let their scripts\n> read and parse.  9c00de5 may have given an enhancement to these scripts in\n> the sense that they can now respond to an empty input from the end user,\n> but this patch forces them to change the way they parse the output from\n> the command.\n\nin this patch, the remote url is printed to stderr, instead of stdout,\nso existing scripts should be safe.\n\n> I also think this patch is solving a wrong problem.\n>\n> When an end user does not know which remote ls-remote would be talking to\n> by default, what else does he *not* know?  Probably which remote \"pull\"\n> would be fetching from and what branch it would be merging with?  Doesn't\n> he have a better command to use to learn that information to reorient\n> himself when he is lost that way?\n\nI'm not sure if there's a command to determine the remote - I'd be\ninterested to know it, if there's one.\n\nThat aside, I believe this patch as an attempt at improving usability.\n\nCompare (pre-patch):\n\n  $ git ls-remote\n  (scratch head)\n  $ git-x # to determine which remote we listed refs from\n\nwith (post-patch):\n\n  $ git ls-remote\n\nThe advantage is minor, but I feel there's some added convenience.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"141681","messageId":"20100514161743.GA1957@progeny.tock","threadId":"23757","inReplyTo":"AANLkTinxm8hwX53LE9_7rDPoKs9UnGAyFFfVcoh-WGxE@mail.gmail.com","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-14T16:17:44Z","receivedAt":"2010-05-14T16:17:44Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Tay Ray Chuan wrote:\n> On Wed, May 12, 2010 at 1:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n\n>> I cannot convince myself that this is a good change, as I've always\n>> thought \"ls-remote\" output as something people want to let their scripts\n>> read and parse.  9c00de5 may have given an enhancement to these scripts in\n>> the sense that they can now respond to an empty input from the end user,\n>> but this patch forces them to change the way they parse the output from\n>> the command.\n\nWould 9c00de5 be so useful for scripts?  I suspect the typical script\ndoes\n\n  git ls-remote \"$remote\"\n\nso to use the new default it would need adjusting.\n\nRun by hand, 'ls-remote | grep heads' can be quite useful.\n\n> in this patch, the remote url is printed to stderr, instead of stdout,\n> so existing scripts should be safe.\n>\n>> I also think this patch is solving a wrong problem.\n>>\n>> When an end user does not know which remote ls-remote would be talking to\n>> by default, what else does he *not* know?  Probably which remote \"pull\"\n>> would be fetching from\n[...]\n\nI think I see what you are saying, and for scripts, that really would\nbe the most useful thing.  Then the script could use something like\n\n  if test -z \"$remote\"\n  then\n\tremote=$(git branch --get-remote --current)\n  fi\n  git ls-remote \"$remote\"\n\nwhich would be much better than\n\n  git ls-remote ${remote:+\"$remote\"} 2>/dev/null\n\nbecause it does not suppress error messages.\n\nFor manual use of ls-remote, on the other hand, I can see the use of\nthe reminder.\n\nJonathan\n"},{"id":"141718","messageId":"AANLkTimTKiGxpVelj9rVV_BV-f8NiKlQHpov38ojlfFq@mail.gmail.com","threadId":"23757","inReplyTo":"20100514161743.GA1957@progeny.tock","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-05-15T09:56:20Z","receivedAt":"2010-05-15T09:56:20Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"On Sat, May 15, 2010 at 12:17 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Tay Ray Chuan wrote:\n>> On Wed, May 12, 2010 at 1:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>>> I cannot convince myself that this is a good change, as I've always\n>>> thought \"ls-remote\" output as something people want to let their scripts\n>>> read and parse.  9c00de5 may have given an enhancement to these scripts in\n>>> the sense that they can now respond to an empty input from the end user,\n>>> but this patch forces them to change the way they parse the output from\n>>> the command.\n>\n> Would 9c00de5 be so useful for scripts?  I suspect the typical script\n> does\n>\n>  git ls-remote \"$remote\"\n>\n> so to use the new default it would need adjusting.\n\nRight, existing scripts that use git-ls-remote are unlikely to be\naffected by 9c00de5, or this patch, for that matter.\n\n>> in this patch, the remote url is printed to stderr, instead of stdout,\n>> so existing scripts should be safe.\n>>\n>>> I also think this patch is solving a wrong problem.\n>>>\n>>> When an end user does not know which remote ls-remote would be talking to\n>>> by default, what else does he *not* know?  Probably which remote \"pull\"\n>>> would be fetching from\n> [...]\n>\n> I think I see what you are saying, and for scripts, that really would\n> be the most useful thing.  Then the script could use something like\n>\n>  if test -z \"$remote\"\n>  then\n>        remote=$(git branch --get-remote --current)\n>  fi\n>  git ls-remote \"$remote\"\n\nJust curious - when did git-branch learn \"--get-remote\"? Or \"--current\"?\n\n-- \nCheers,\nRay Chuan\n"},{"id":"141737","messageId":"20100515162002.GA2592@progeny.tock","threadId":"23757","inReplyTo":"AANLkTimTKiGxpVelj9rVV_BV-f8NiKlQHpov38ojlfFq@mail.gmail.com","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-15T16:20:02Z","receivedAt":"2010-05-15T16:20:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Tay Ray Chuan wrote:\n> On Sat, May 15, 2010 at 12:17 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>> I think I see what you are saying, and for scripts, that really would\n>> be the most useful thing.  Then the script could use something like\n>>\n>>  if test -z \"$remote\"\n>>  then\n>>        remote=$(git branch --get-remote --current)\n>>  fi\n>>  git ls-remote \"$remote\"\n>\n> Just curious - when did git-branch learn \"--get-remote\"? Or \"--current\"?\n\nIt didn’t.  I was just saying that it should (or we should provide some\ncommands to that effect).  What do you think?\n\nMaybe later today...\nJonathan\n"},{"id":"141755","messageId":"C21B68F7-E430-4BCA-A1D1-80446B0B76DE@adacore.com","threadId":"23757","inReplyTo":"AANLkTinxm8hwX53LE9_7rDPoKs9UnGAyFFfVcoh-WGxE@mail.gmail.com","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Geert Bosch","fromEmail":"bosch@adacore.com","sentAt":"2010-05-16T02:14:48Z","receivedAt":"2010-05-16T02:14:48Z","isPatch":true,"sender":{"key":"bosch@adacore.com","avatar":null},"body":"\nOn May 13, 2010, at 23:07, Tay Ray Chuan wrote:\n\n>> When an end user does not know which remote ls-remote would be talking to\n>> by default, what else does he *not* know?  Probably which remote \"pull\"\n>> would be fetching from and what branch it would be merging with?  Doesn't\n>> he have a better command to use to learn that information to reorient\n>> himself when he is lost that way?\n> \n> I'm not sure if there's a command to determine the remote - I'd be\n> interested to know it, if there's one.\n\nWhat git seems to be missing is a \"git info\" command, which\nwould print out essentially something like what \"svn info\" does:\nname of remote repo that we're tracking, name of current branch,\ndate/author/subject of last commit.\n\nRegards,\n  -Geert\n"},{"id":"141764","messageId":"AANLkTikKZAinLGeRMnqUPsTbBjMiAQuOCXxr4VEPBhHW@mail.gmail.com","threadId":"23757","inReplyTo":"C21B68F7-E430-4BCA-A1D1-80446B0B76DE@adacore.com","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-05-16T10:36:22Z","receivedAt":"2010-05-16T10:36:22Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sun, May 16, 2010 at 04:14, Geert Bosch <bosch@adacore.com> wrote:\n> What git seems to be missing is a \"git info\" command, which\n> would print out essentially something like what \"svn info\" does:\n> name of remote repo that we're tracking, name of current branch,\n> date/author/subject of last commit.\n\nYou can get information about the remote with:\n\n$ git remote -v\n\nAnd then for the branch etc you can do (although it doesn't list the author):\n\n$ git branch -v\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"141776","messageId":"47A48A85-CAFC-4B8B-9D24-869A6ABC8EF1@adacore.com","threadId":"23757","inReplyTo":"AANLkTikKZAinLGeRMnqUPsTbBjMiAQuOCXxr4VEPBhHW@mail.gmail.com","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Geert Bosch","fromEmail":"bosch@adacore.com","sentAt":"2010-05-16T17:27:15Z","receivedAt":"2010-05-16T17:27:15Z","isPatch":true,"sender":{"key":"bosch@adacore.com","avatar":null},"body":"\nOn May 16, 2010, at 06:36, Sverre Rabbelier wrote:\n\n> On Sun, May 16, 2010 at 04:14, Geert Bosch <bosch@adacore.com> wrote:\n>> What git seems to be missing is a \"git info\" command, which\n>> would print out essentially something like what \"svn info\" does:\n>> name of remote repo that we're tracking, name of current branch,\n>> date/author/subject of last commit.\n> \n> You can get information about the remote with:\n> \n> $ git remote -v\n\ngeert-boschs-computer:/tmp%ssh kwai git init --bare /work/bosch/temp.git\nInitialized empty Git repository in /export/work/bosch/temp.git/\ngeert-boschs-computer:/tmp%git init temp\nInitialized empty Git repository in /private/tmp/temp/.git/\ngeert-boschs-computer:/tmp%cd temp\ngeert-boschs-computer:/tmp/temp%echo hello>world\ngeert-boschs-computer:/tmp/temp%git add world\ngeert-boschs-computer:/tmp/temp%git commit -m \"Add hello\" world\n[master (root-commit) 10837b9] Add hello\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 world\ngeert-boschs-computer:/tmp/temp%git push --all kwai:/work/bosch/temp.git\nCounting objects: 3, done.\nWriting objects: 100% (3/3), 211 bytes, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nTo kwai:/work/bosch/temp.git\n * [new branch]      master -> master\ngeert-boschs-computer:/tmp/temp%git push -u --all kwai:/work/bosch/temp.git\nBranch master set up to track remote branch master from kwai:/work/bosch/temp.git.\nEverything up-to-date\ngeert-boschs-computer:/tmp/temp%git remote -v\ngeert-boschs-computer:/tmp/temp%git push\nEverything up-to-date\n\nSo, there is a remote that gets used automatically by git push and git pull,\nbut it's not obvious which one. Basically, a \"git info\" command should give\na dozen lines or so that allows one quickly to identify a repository, including\ncurrent branch, any remote it tracks, last commit, wether the working directory\nis clean, wether anything is staged for commit, wether the repository tracks\na non-git (svn, bzr, hg) repository.\n\n> \n> And then for the branch etc you can do (although it doesn't list the author):\n> \n> $ git branch -v\nWhile both commands are very useful, I think a case can be made for a single\ncommand that pulls together enough information in a few lines that it is clear.\n\nI'll see if I can cobble something up."},{"id":"141963","messageId":"7v632i8zzy.fsf@alter.siamese.dyndns.org","threadId":"23757","inReplyTo":"20100515162002.GA2592@progeny.tock","subject":"Re: [PATCH v2] ls-remote: print URL when no repo is specified","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-20T13:27:29Z","receivedAt":"2010-05-20T13:27:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Tay Ray Chuan wrote:\n>> On Sat, May 15, 2010 at 12:17 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>\n>>> I think I see what you are saying, and for scripts, that really would\n>>> be the most useful thing.  Then the script could use something like\n>>>\n>>>  if test -z \"$remote\"\n>>>  then\n>>>        remote=$(git branch --get-remote --current)\n>>>  fi\n>>>  git ls-remote \"$remote\"\n>>\n>> Just curious - when did git-branch learn \"--get-remote\"? Or \"--current\"?\n>\n> It didn’t.  I was just saying that it should (or we should provide some\n> commands to that effect).  What do you think?\n\nI think you said what I meant to say much more clearly.  Thanks.\n"}]}