{"thread":{"id":"9166","subject":"[RFC] describe: add option --dirty","startedAt":"2007-07-23T06:35:50Z","lastAt":"2007-07-23T08:52:54Z","messageCount":7,"participants":["Yasushi SHOJI","Junio C Hamano","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"48268","messageId":"87odi3mxtl.wl@mail2.atmark-techno.com","threadId":"9166","inReplyTo":null,"subject":"[RFC] describe: add option --dirty","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2007-07-23T06:35:50Z","receivedAt":"2007-07-23T06:35:50Z","isPatch":false,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"when --dirty is given, git describe will check the working tree and\nappend \"-dirty\" to describe string if the tree is dirty.\n---\nI'm not sure this is good idea or the current way (using diff-index in\nshell script) is more prefered.\n\none thing I found out is that we s/-/./g the out put of describe\nbefore we append \"-dirty\".  this patch doesn't take care that. so with\nthis patch what we get is either\n\n\tv1.5.3-rc2-840-g1c0e2-dirty, or\n\tv1.5.3.rc2.840.g1c0e2.dirty\n\nif we don't put more complecated sed command in GIT-VERSION-GEN.\n\nanyway, comments welcome.\n\nps. another thing I don't like about this patch is that it changed to\npass prefix down to describe() as the last argument because I was lazy\nto call cmd_diff_index() in describe().  if there is better way to do\nit, please let me know.\n\n\n Documentation/git-describe.txt |    5 ++++-\n builtin-describe.c             |   29 ++++++++++++++++++++++-------\n 2 files changed, 26 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\nindex f0bcb61..627c4d5 100644\n--- a/Documentation/git-describe.txt\n+++ b/Documentation/git-describe.txt\n@@ -9,7 +9,7 @@ git-describe - Show the most recent tag that is reachable from a commit\n SYNOPSIS\n --------\n 'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>]\n-               [--candidates=<n>] [--debug]\n+               [--candidates=<n>] [--debug] [--dirty]\n                <committish>...\n \n DESCRIPTION\n@@ -53,6 +53,9 @@ OPTIONS\n \tbeing employed to standard error.  The tag name will still\n \tbe printed to standard out.\n \n+--dirty::\n+\tAppend \"-dirty\" to describe string if working tree is dirty.\n+\n EXAMPLES\n --------\n \ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex e94f867..bebc16b 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -9,11 +9,12 @@\n #define MAX_TAGS\t(FLAG_BITS - 1)\n \n static const char describe_usage[] =\n-\"git-describe [--all] [--tags] [--contains] [--abbrev=<n>] [--candidates] [--debug] <committish>*\";\n+\"git-describe [--all] [--tags] [--contains] [--abbrev=<n>] [--candidates] [--debug] [--dirty] <committish>*\";\n \n static int debug;\t/* Display lots of verbose info */\n static int all;\t/* Default to annotated tags only */\n static int tags;\t/* But allow any tags if --tags is specified */\n+static int check_dirty;\t/* Append \"-dirty\" to describe string if working tree is dirty */\n static int abbrev = DEFAULT_ABBREV;\n static int max_candidates = 10;\n \n@@ -125,7 +126,7 @@ static unsigned long finish_depth_computation(\n \treturn seen_commits;\n }\n \n-static void describe(const char *arg, int last_one)\n+static void describe(const char *arg, int last_one, const char *prefix)\n {\n \tunsigned char sha1[20];\n \tstruct commit *cmit, *gave_up_on = NULL;\n@@ -135,6 +136,7 @@ static void describe(const char *arg, int last_one)\n \tstruct possible_tag all_matches[MAX_TAGS];\n \tunsigned int match_cnt = 0, annotated_cnt = 0, cur_match;\n \tunsigned long seen_commits = 0;\n+\tchar *dirty_string = \"\";\n \n \tif (get_sha1(arg, sha1))\n \t\tdie(\"Not a valid object name %s\", arg);\n@@ -229,12 +231,23 @@ static void describe(const char *arg, int last_one)\n \t\t\t\tsha1_to_hex(gave_up_on->object.sha1));\n \t\t}\n \t}\n+\tif (check_dirty) {\n+\t\tconst char **args = xmalloc(5 * sizeof(char*));\n+\t\targs[0] = \"diff-index\";\n+\t\targs[1] = \"--quiet\";\n+\t\targs[2] = \"--name-only\";\n+\t\targs[3] = \"HEAD\";\n+\t\targs[4] = NULL;\n+\t\tif (cmd_diff_index(4, args, prefix))\n+\t\t\tdirty_string = \"-dirty\";\n+\t}\n \tif (abbrev == 0)\n-\t\tprintf(\"%s\\n\", all_matches[0].name->path );\n+\t\tprintf(\"%s%s\\n\", all_matches[0].name->path, dirty_string);\n \telse\n-\t\tprintf(\"%s-%d-g%s\\n\", all_matches[0].name->path,\n+\t\tprintf(\"%s-%d-g%s%s\\n\", all_matches[0].name->path,\n \t\t       all_matches[0].depth,\n-\t\t       find_unique_abbrev(cmit->object.sha1, abbrev));\n+\t\t       find_unique_abbrev(cmit->object.sha1, abbrev),\n+\t\t       dirty_string);\n \n \tif (!last_one)\n \t\tclear_commit_marks(cmit, -1);\n@@ -250,6 +263,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \n \t\tif (*arg != '-')\n \t\t\tbreak;\n+\t\telse if (!strcmp(arg, \"--dirty\"))\n+\t\t\tcheck_dirty = 1;\n \t\telse if (!strcmp(arg, \"--contains\"))\n \t\t\tcontains = 1;\n \t\telse if (!strcmp(arg, \"--debug\"))\n@@ -290,10 +305,10 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (argc <= i)\n-\t\tdescribe(\"HEAD\", 1);\n+\t\tdescribe(\"HEAD\", 1, prefix);\n \telse\n \t\twhile (i < argc) {\n-\t\t\tdescribe(argv[i], (i == argc - 1));\n+\t\t\tdescribe(argv[i], (i == argc - 1), prefix);\n \t\t\ti++;\n \t\t}\n \n-- \n1.5.3.rc2.4.g726f9\n"},{"id":"48270","messageId":"7vsl7fmwud.fsf@assigned-by-dhcp.cox.net","threadId":"9166","inReplyTo":"87odi3mxtl.wl@mail2.atmark-techno.com","subject":"Re: [RFC] describe: add option --dirty","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-23T06:56:58Z","receivedAt":"2007-07-23T06:56:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yasushi SHOJI <yashi@atmark-techno.com> writes:\n\n> when --dirty is given, git describe will check the working tree and\n> append \"-dirty\" to describe string if the tree is dirty.\n> ---\n> I'm not sure this is good idea or the current way (using diff-index in\n> shell script) is more prefered.\n\nHmph, this makes sense _ONLY_ for HEAD, doesn't it?\n\nIOW, what should this output?\n\n\t$ git checkout v1.5.0 ;# detached HEAD\n        $ git reset --hard  ;# clean slate\n        $ echo >>Makefile ;# not anymore\n        $ git describe --dirty v1.4.0^1\n\nShould it say \"v1.4.0-rc2-156-g0a8f4f0-dirty\"?  The dirtiness\ndoes not have anything to do with commit v1.4.0^1, so...\n"},{"id":"48271","messageId":"20070723065912.GG32566@spearce.org","threadId":"9166","inReplyTo":"87odi3mxtl.wl@mail2.atmark-techno.com","subject":"Re: [RFC] describe: add option --dirty","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-07-23T06:59:12Z","receivedAt":"2007-07-23T06:59:12Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Yasushi SHOJI <yashi@atmark-techno.com> wrote:\n> when --dirty is given, git describe will check the working tree and\n> append \"-dirty\" to describe string if the tree is dirty.\n> ---\n> I'm not sure this is good idea or the current way (using diff-index in\n> shell script) is more prefered.\n\nYea, I'm actually torn on this.  A lot of people like the output of\ngit-describe for versions (where a lot is at least me!) and yet I\nalso always tack in the -dirty if the directory is dirty according\nto diff-index.  So having this built right into git-describe is\nactually quite handy.  It simplifies a little bit of build rule\nlogic.\n\n> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\n> @@ -53,6 +53,9 @@ OPTIONS\n>  \tbeing employed to standard error.  The tag name will still\n>  \tbe printed to standard out.\n>  \n> +--dirty::\n> +\tAppend \"-dirty\" to describe string if working tree is dirty.\n> +\n\nIt requires a working directory.  Running this in a bare repository\nwith --dirty won't work.  You might want to discuss that in the\ndocumentation.\n\n> diff --git a/builtin-describe.c b/builtin-describe.c\n> @@ -229,12 +231,23 @@ static void describe(const char *arg, int last_one)\n>  \t\t\t\tsha1_to_hex(gave_up_on->object.sha1));\n>  \t\t}\n>  \t}\n> +\tif (check_dirty) {\n> +\t\tconst char **args = xmalloc(5 * sizeof(char*));\n> +\t\targs[0] = \"diff-index\";\n> +\t\targs[1] = \"--quiet\";\n> +\t\targs[2] = \"--name-only\";\n> +\t\targs[3] = \"HEAD\";\n> +\t\targs[4] = NULL;\n> +\t\tif (cmd_diff_index(4, args, prefix))\n> +\t\t\tdirty_string = \"-dirty\";\n> +\t}\n\nSo if I describe two different commits at once in the same working\ntree you are going to run diff-index twice?  That's not a great idea.\nThe outcome of diff-index won't change between those two commits.\nBetter to compute this up front before calling the describe()\nfunction, and instead of passing in prefix pass in dirty_string.\nOr just make it a global, like you did to the option flag.\n\n>  \tif (abbrev == 0)\n> -\t\tprintf(\"%s\\n\", all_matches[0].name->path );\n> +\t\tprintf(\"%s%s\\n\", all_matches[0].name->path, dirty_string);\n>  \telse\n> -\t\tprintf(\"%s-%d-g%s\\n\", all_matches[0].name->path,\n> +\t\tprintf(\"%s-%d-g%s%s\\n\", all_matches[0].name->path,\n>  \t\t       all_matches[0].depth,\n> -\t\t       find_unique_abbrev(cmit->object.sha1, abbrev));\n> +\t\t       find_unique_abbrev(cmit->object.sha1, abbrev),\n> +\t\t       dirty_string);\n>  \n>  \tif (!last_one)\n>  \t\tclear_commit_marks(cmit, -1);\n\nSo if HEAD is exactly matching a tag you don't output the -dirty\nsuffix, even if the working tree is dirty?  That's counter to the\ndocumentation above.  See l.150-154, we break out of the describe\nfunction very quickly if there is a tag on the input commit.\n\n-- \nShawn.\n"},{"id":"48273","messageId":"20070723070818.GI32566@spearce.org","threadId":"9166","inReplyTo":"7vsl7fmwud.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] describe: add option --dirty","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-07-23T07:08:18Z","receivedAt":"2007-07-23T07:08:18Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> Yasushi SHOJI <yashi@atmark-techno.com> writes:\n> \n> > when --dirty is given, git describe will check the working tree and\n> > append \"-dirty\" to describe string if the tree is dirty.\n> > ---\n> > I'm not sure this is good idea or the current way (using diff-index in\n> > shell script) is more prefered.\n> \n> Hmph, this makes sense _ONLY_ for HEAD, doesn't it?\n> \n> IOW, what should this output?\n> \n> \t$ git checkout v1.5.0 ;# detached HEAD\n>         $ git reset --hard  ;# clean slate\n>         $ echo >>Makefile ;# not anymore\n>         $ git describe --dirty v1.4.0^1\n> \n> Should it say \"v1.4.0-rc2-156-g0a8f4f0-dirty\"?  The dirtiness\n> does not have anything to do with commit v1.4.0^1, so...\n\nGood catch.  I had that in my mind when I was reading the patch,\nbut failed to mention it.  I blame metze on #git, he interrupted\nmy train of thought.  ;-)\n\n\nI think the answer is the user passes either --dirty OR one or\nmore commit-ish.  But not --dirty and a commit-ish.  In other words\nyou can either describe the working directory state, or a commit,\nbut not both at once.  Which also neatly solves my issue with\ndiff-index running more than once.\n\n-- \nShawn.\n"},{"id":"48278","messageId":"87lkd7mu71.wl@mail2.atmark-techno.com","threadId":"9166","inReplyTo":"20070723070818.GI32566@spearce.org","subject":"Re: [RFC] describe: add option --dirty","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2007-07-23T07:54:10Z","receivedAt":"2007-07-23T07:54:10Z","isPatch":false,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"At Mon, 23 Jul 2007 03:08:18 -0400,\nShawn O. Pearce wrote:\n> \n> Junio C Hamano <gitster@pobox.com> wrote:\n> > Yasushi SHOJI <yashi@atmark-techno.com> writes:\n> > \n> > > when --dirty is given, git describe will check the working tree and\n> > > append \"-dirty\" to describe string if the tree is dirty.\n> > > ---\n> > > I'm not sure this is good idea or the current way (using diff-index in\n> > > shell script) is more prefered.\n> > \n> > Hmph, this makes sense _ONLY_ for HEAD, doesn't it?\n> > \n> > IOW, what should this output?\n> > \n> > \t$ git checkout v1.5.0 ;# detached HEAD\n> >         $ git reset --hard  ;# clean slate\n> >         $ echo >>Makefile ;# not anymore\n> >         $ git describe --dirty v1.4.0^1\n> > \n> > Should it say \"v1.4.0-rc2-156-g0a8f4f0-dirty\"?  The dirtiness\n> > does not have anything to do with commit v1.4.0^1, so...\n> \n> Good catch.  I had that in my mind when I was reading the patch,\n> but failed to mention it.  I blame metze on #git, he interrupted\n> my train of thought.  ;-)\n\nI knew the issue be failed to note about it.  Thanks.\n\n> I think the answer is the user passes either --dirty OR one or\n> more commit-ish.  But not --dirty and a commit-ish.  In other words\n> you can either describe the working directory state, or a commit,\n> but not both at once.  Which also neatly solves my issue with\n> diff-index running more than once.\n\nSo the point is would it be worth implementing in usable form?\n\n>From the comments I'd add an option \"--workinig-tree\" instead of\n--dirty to describe the working tree.  because that, the special case,\nis what we want after all,\n\nsynopsis would be:\n\n\tSYNOPSIS\n\t--------\n\t'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>]\n\t               [--candidates=<n>] [--debug]\n\t               --working-tree | <committish>...\n\t    :\n\t    :\n\t--working-tree::\n\t\tDescribe the working tree instead of committishes.  if the\n\t\tworking tree is dirty, the describe string will have \"-dirty\"\n\t\tappended.\n\t\n\t\tAs you can assume from the name, this option requires working\n\t\ttree; running it on a bare repository will fail.\n\nwhat do you think?\n-- \n         yashi\n"},{"id":"48281","messageId":"20070723075834.GK32566@spearce.org","threadId":"9166","inReplyTo":"87lkd7mu71.wl@mail2.atmark-techno.com","subject":"Re: [RFC] describe: add option --dirty","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-07-23T07:58:34Z","receivedAt":"2007-07-23T07:58:34Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Yasushi SHOJI <yashi@atmark-techno.com> wrote:\n> From the comments I'd add an option \"--workinig-tree\" instead of\n> --dirty to describe the working tree.  because that, the special case,\n> is what we want after all,\n> \n> synopsis would be:\n> \n> \tSYNOPSIS\n> \t--------\n> \t'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>]\n> \t               [--candidates=<n>] [--debug]\n> \t               --working-tree | <committish>...\n> \t    :\n> \t    :\n> \t--working-tree::\n> \t\tDescribe the working tree instead of committishes.  if the\n> \t\tworking tree is dirty, the describe string will have \"-dirty\"\n> \t\tappended.\n> \t\n> \t\tAs you can assume from the name, this option requires working\n> \t\ttree; running it on a bare repository will fail.\n> \n> what do you think?\n\nThat's reasonable.  It seems like a lot of work in core Git just\nto avoid a small chunk of shell, but I think almost everyone has\nthat same small chunk of shell in their build scripts...\n\n-- \nShawn.\n"},{"id":"48284","messageId":"87k5srmrh5.wl@mail2.atmark-techno.com","threadId":"9166","inReplyTo":"20070723075834.GK32566@spearce.org","subject":"Re: [RFC] describe: add option --dirty","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2007-07-23T08:52:54Z","receivedAt":"2007-07-23T08:52:54Z","isPatch":false,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"At Mon, 23 Jul 2007 03:58:34 -0400,\nShawn O. Pearce wrote:\n> \n> Yasushi SHOJI <yashi@atmark-techno.com> wrote:\n> > From the comments I'd add an option \"--workinig-tree\" instead of\n> > --dirty to describe the working tree.  because that, the special case,\n> > is what we want after all,\n> > \n> > synopsis would be:\n> > \n> > \tSYNOPSIS\n> > \t--------\n> > \t'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>]\n> > \t               [--candidates=<n>] [--debug]\n> > \t               --working-tree | <committish>...\n> > \t    :\n> > \t    :\n> > \t--working-tree::\n> > \t\tDescribe the working tree instead of committishes.  if the\n> > \t\tworking tree is dirty, the describe string will have \"-dirty\"\n> > \t\tappended.\n> > \t\n> > \t\tAs you can assume from the name, this option requires working\n> > \t\ttree; running it on a bare repository will fail.\n> > \n> > what do you think?\n> \n> That's reasonable.  It seems like a lot of work in core Git just\n> to avoid a small chunk of shell, but I think almost everyone has\n> that same small chunk of shell in their build scripts...\n\nit's not that much.  here it is.  hope you like it.\n\n\n>From 25acf0fad4866b87998b51f1e66f540f2bcc5f0d Mon Sep 17 00:00:00 2001\nFrom: Yasushi SHOJI <yashi@atmark-techno.com>\nDate: Mon, 23 Jul 2007 17:49:11 +0900\nSubject: [PATCH] describe: add a new option --working-tree\n\nMany people like to use git-describe for version number, and yet\npeople always tack in the -dirty if the directory is dirty according\nto diff-index. So this patch tries to scratch the itchy.\n\nWith --working-tree, the command will describe the working tree\ninstead of committishes. If the working tree is dirty, the describe\nstring will have \"-dirty\" appended.\n\nAs you can assume from the name, this option requires working tree.\nrunning it on a bare repository will fail.\n\nSigned-off-by: Yasushi SHOJI <yashi@atmark-techno.com>\n---\n Documentation/git-describe.txt |   10 +++++++++-\n builtin-describe.c             |   38 +++++++++++++++++++++++++++++++-------\n 2 files changed, 40 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\nindex f0bcb61..d9b1550 100644\n--- a/Documentation/git-describe.txt\n+++ b/Documentation/git-describe.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n 'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>]\n                [--candidates=<n>] [--debug]\n-               <committish>...\n+               --working-tree | <committish>...\n \n DESCRIPTION\n -----------\n@@ -53,6 +53,14 @@ OPTIONS\n \tbeing employed to standard error.  The tag name will still\n \tbe printed to standard out.\n \n+--working-tree::\n+\tDescribe the working tree instead of committishes.  if the\n+\tworking tree is dirty, the describe string will have \"-dirty\"\n+\tappended.\n+\n+\tAs you can assume from the name, this option requires a\n+\tworking tree. Running it on a bare repository will fail.\n+\n EXAMPLES\n --------\n \ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex e94f867..1c58480 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -9,11 +9,12 @@\n #define MAX_TAGS\t(FLAG_BITS - 1)\n \n static const char describe_usage[] =\n-\"git-describe [--all] [--tags] [--contains] [--abbrev=<n>] [--candidates] [--debug] <committish>*\";\n+\"git-describe [--all] [--tags] [--contains] [--abbrev=<n>] [--candidates] [--debug] --working-tree | <committish>*\";\n \n static int debug;\t/* Display lots of verbose info */\n static int all;\t/* Default to annotated tags only */\n static int tags;\t/* But allow any tags if --tags is specified */\n+static int working_tree;/* describe the working tree instead of committish */\n static int abbrev = DEFAULT_ABBREV;\n static int max_candidates = 10;\n \n@@ -125,7 +126,7 @@ static unsigned long finish_depth_computation(\n \treturn seen_commits;\n }\n \n-static void describe(const char *arg, int last_one)\n+static void describe(const char *arg, int last_one, int dirty)\n {\n \tunsigned char sha1[20];\n \tstruct commit *cmit, *gave_up_on = NULL;\n@@ -135,6 +136,7 @@ static void describe(const char *arg, int last_one)\n \tstruct possible_tag all_matches[MAX_TAGS];\n \tunsigned int match_cnt = 0, annotated_cnt = 0, cur_match;\n \tunsigned long seen_commits = 0;\n+\tchar *dirty_string = dirty ? \"-dirty\" : \"\";\n \n \tif (get_sha1(arg, sha1))\n \t\tdie(\"Not a valid object name %s\", arg);\n@@ -230,11 +232,12 @@ static void describe(const char *arg, int last_one)\n \t\t}\n \t}\n \tif (abbrev == 0)\n-\t\tprintf(\"%s\\n\", all_matches[0].name->path );\n+\t\tprintf(\"%s%s\\n\", all_matches[0].name->path, dirty_string);\n \telse\n-\t\tprintf(\"%s-%d-g%s\\n\", all_matches[0].name->path,\n+\t\tprintf(\"%s-%d-g%s%s\\n\", all_matches[0].name->path,\n \t\t       all_matches[0].depth,\n-\t\t       find_unique_abbrev(cmit->object.sha1, abbrev));\n+\t\t       find_unique_abbrev(cmit->object.sha1, abbrev),\n+\t\t       dirty_string);\n \n \tif (!last_one)\n \t\tclear_commit_marks(cmit, -1);\n@@ -244,12 +247,15 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n \tint contains = 0;\n+\tint dirty = 0;\n \n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n \t\tif (*arg != '-')\n \t\t\tbreak;\n+\t\telse if (!strcmp(arg, \"--working-tree\"))\n+\t\t\tworking_tree = 1;\n \t\telse if (!strcmp(arg, \"--contains\"))\n \t\t\tcontains = 1;\n \t\telse if (!strcmp(arg, \"--debug\"))\n@@ -276,6 +282,24 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \n \tsave_commit_buffer = 0;\n \n+\tif (working_tree) {\n+\t\tconst char **args;\n+\n+\t\tif (!is_inside_work_tree() || is_inside_git_dir())\n+\t\t\tdie(\"%s with --working-tree must be run in a working tree\", argv[0]);\n+\t\tif (argc > i)\n+\t\t\tdie(\"--working-tree doesn't take any committish\\n\");\n+\n+\t\targs = xmalloc(5 * sizeof(char*));\n+\t\targs[0] = \"diff-index\";\n+\t\targs[1] = \"--quiet\";\n+\t\targs[2] = \"--name-only\";\n+\t\targs[3] = \"HEAD\";\n+\t\targs[4] = NULL;\n+\t\tif (cmd_diff_index(4, args, prefix))\n+\t\t\tdirty = 1;\n+\t}\n+\n \tif (contains) {\n \t\tconst char **args = xmalloc((4 + argc - i) * sizeof(char*));\n \t\targs[0] = \"name-rev\";\n@@ -290,10 +314,10 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (argc <= i)\n-\t\tdescribe(\"HEAD\", 1);\n+\t\tdescribe(\"HEAD\", 1, dirty);\n \telse\n \t\twhile (i < argc) {\n-\t\t\tdescribe(argv[i], (i == argc - 1));\n+\t\t\tdescribe(argv[i], (i == argc - 1), dirty);\n \t\t\ti++;\n \t\t}\n \n-- \n1.5.3.rc2.4.g726f9\n"}]}