[PATCH v2 5/8] rename_ref(): inline calls to write_ref_sha1() from this function

2015-05-09 Thread Michael Haggerty
Most of what it does is unneeded from these call sites.

Signed-off-by: Michael Haggerty 
---
 refs.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/refs.c b/refs.c
index 7661db9..18ce8e6 100644
--- a/refs.c
+++ b/refs.c
@@ -2799,8 +2799,9 @@ static int rename_ref_available(const char *oldname, 
const char *newname)
return ret;
 }
 
-static int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1,
- const char *logmsg);
+static int write_ref_to_lockfile(struct ref_lock *lock, const unsigned char 
*sha1);
+static int commit_ref_update(struct ref_lock *lock,
+const unsigned char *sha1, const char *logmsg);
 
 int rename_ref(const char *oldrefname, const char *newrefname, const char 
*logmsg)
 {
@@ -2859,7 +2860,9 @@ int rename_ref(const char *oldrefname, const char 
*newrefname, const char *logms
}
lock->force_write = 1;
hashcpy(lock->old_sha1, orig_sha1);
-   if (write_ref_sha1(lock, orig_sha1, logmsg)) {
+
+   if (write_ref_to_lockfile(lock, orig_sha1) ||
+   commit_ref_update(lock, orig_sha1, logmsg)) {
error("unable to write current sha1 into %s", newrefname);
goto rollback;
}
@@ -2876,7 +2879,8 @@ int rename_ref(const char *oldrefname, const char 
*newrefname, const char *logms
lock->force_write = 1;
flag = log_all_ref_updates;
log_all_ref_updates = 0;
-   if (write_ref_sha1(lock, orig_sha1, NULL))
+   if (write_ref_to_lockfile(lock, orig_sha1) ||
+   commit_ref_update(lock, orig_sha1, NULL))
error("unable to write current sha1 into %s", oldrefname);
log_all_ref_updates = flag;
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 5/6] new-command.txt: mention the common command groups

2015-05-09 Thread Sébastien Guimmara
In the 6. step, add information about the common group commands
found in command-list.txt.

Signed-off-by: Sébastien Guimmara 
---
 Documentation/howto/new-command.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/howto/new-command.txt 
b/Documentation/howto/new-command.txt
index d7de5a3..e7b0cc2 100644
--- a/Documentation/howto/new-command.txt
+++ b/Documentation/howto/new-command.txt
@@ -95,7 +95,9 @@ your language, document it in the INSTALL file.
 that categorizes commands by type, so they can be listed in appropriate
 subsections in the documentation's summary command list.  Add an entry
 for yours.  To understand the categories, look at git-commands.txt
-in the main directory.
+in the main directory. If the new command is part of the typical Git
+workflow and you believe it's common enough to be mentioned in
+'git help', map this command to a common group in the column [common]
 
 7. Give the maintainer one paragraph to include in the RelNotes file
 to describe the new feature; a good place to do so is in the cover
-- 
2.4.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 3/6] command-list.txt: group common commands by theme

2015-05-09 Thread Sébastien Guimmara
Declare groups for common commands in the [common] block,
followed by group names and descriptions:

[common]
init start a working area (see also: git help tutorial)
worktree work on the current change (see also: git [...]
info examine the history and state (see also: git [...]
history  grow, mark and tweak your history
remote   collaborate (see also: git help workflows)

Some descriptions include a 'see also' to redirect user to more
detailed documentation.

Then, in the [commands] block, map all common commands with a group:

[commands]
git-addmainporcelain worktree
git-branch mainporcelain history
git-checkout   mainporcelain history
[...]

So that 'git help' outputs those commands in headered groups.

Helped-by: Junio C Hamano 
Helped-by:  Emma Jane Hogbin Westby 
Signed-off-by: Sébastien Guimmara 
---
 command-list.txt | 56 ++--
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/command-list.txt b/command-list.txt
index f1eae08..7e7ce53 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -1,29 +1,41 @@
+# common commands are grouped by themes
+# this order is the same that output by 'git help'
+# map each common commands in the [commands] list to one of the groups.
+# a command should not be marked both [deprecated] and [common]
+[common]
+init start a working area (see also: git help tutorial)
+worktree work on the current change (see also: git help everyday)
+info examine the history and state (see also: git help revisions)
+history  grow, mark and tweak your history
+remote   collaborate (see also: git help workflows)
+
 # List of known git commands.
-# command name category [deprecated] [common]
-git-add mainporcelain common
+# command name [deprecated] category[common]
+[commands]
+git-add mainporcelain   worktree
 git-am  mainporcelain
 git-annotateancillaryinterrogators
 git-apply   plumbingmanipulators
 git-archimport  foreignscminterface
 git-archive mainporcelain
-git-bisect  mainporcelain common
+git-bisect  mainporcelain   info
 git-blame   ancillaryinterrogators
-git-branch  mainporcelain common
+git-branch  mainporcelain   history
 git-bundle  mainporcelain
 git-cat-fileplumbinginterrogators
 git-check-attr  purehelpers
 git-check-ignorepurehelpers
 git-check-mailmap   purehelpers
-git-checkoutmainporcelain common
+git-checkoutmainporcelain   history
 git-checkout-index  plumbingmanipulators
 git-check-ref-formatpurehelpers
 git-cherry  ancillaryinterrogators
 git-cherry-pick mainporcelain
 git-citool  mainporcelain
 git-clean   mainporcelain
-git-clone   mainporcelain common
+git-clone   mainporcelain   init
 git-column  purehelpers
-git-commit  mainporcelain common
+git-commit  mainporcelain   history
 git-commit-tree plumbingmanipulators
 git-config  ancillarymanipulators
 git-count-objects   ancillaryinterrogators
@@ -35,14 +47,14 @@ git-cvsimport   foreignscminterface
 git-cvsserver   foreignscminterface
 git-daemon  synchingrepositories
 git-describemainporcelain
-git-diffmainporcelain common
+git-diffmainporcelain   history
 git-diff-files  plumbinginterrogators
 git-diff-index  plumbinginterrogators
 git-diff-tree   plumbinginterrogators
 git-difftoolancillaryinterrogators
 git-fast-exportancillarymanipulators
 git-fast-importancillarymanipulators
-git-fetch   mainporcelain common
+git-fetch   mainporcelain   remote
 git-fetch-pack  synchingrepositories
 git-filter-branch   ancillaryma

[PATCH v5 1/6] generate-cmdlist: parse common group commands

2015-05-09 Thread Sébastien Guimmara
Parse the [common] block to create the array of group descriptions:

static char *common_cmd_groups[] = {
N_("start a working area (see also: git help tutorial)"),
N_("work on the current change (see also: git help everyday)"),
N_("examine the history and state (see also: git help revisions)"),
N_("grow, mark and tweak your history"),
N_("collaborate (see also: git help workflows)"),
};

then map each element of common_cmds[] to a group via its index:

static struct cmdname_help common_cmds[] = {
{"add", N_("Add file contents to the index"), 1},
{"branch", N_("List, create, or delete branches"), 4},
{"checkout", N_("Checkout a branch or paths to the ..."), 4},
{"clone", N_("Clone a repository into a new directory"), 0},
{"commit", N_("Record changes to the repository"), 4},
...
};

so that 'git help' can print those commands grouped by theme.

Only commands tagged with an attribute from [common] are emitted to
common_cmds[].

[commit message by Sébastien Guimmara ]

Signed-off-by: Eric Sunshine 
---
 generate-cmdlist.awk | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 generate-cmdlist.awk

diff --git a/generate-cmdlist.awk b/generate-cmdlist.awk
new file mode 100644
index 000..cbaac88
--- /dev/null
+++ b/generate-cmdlist.awk
@@ -0,0 +1,38 @@
+BEGIN {
+   print "/* Automatically generated by generate-cmdlist.awk */\n"
+   print "struct cmdname_help {"
+   print "\tchar name[16];"
+   print "\tchar help[80];"
+   print "\tunsigned char group;"
+   print "};\n"
+   print "static char *common_cmd_groups[] = {"
+}
+/^#/ || /^[]*$/ { next }
+state == 2 {
+   for (i = 2; i <= NF; i++)
+   if (grp[$i]) {
+   f = "Documentation/"$1".txt"
+   while (getline s  0)
+   if (match(s, $1" - ")) {
+   t = substr(s, length($1" - ") + 1)
+   break
+   }
+   close(f)
+   printf "\t{\"%s\", N_(\"%s\"), %s},\n",
+   substr($1, length("git-") + 1), t, grp[$i] - 1
+   break
+   }
+}
+/\[commands\]/ {
+   print "};\n\nstatic struct cmdname_help common_cmds[] = {"
+   state = 2
+}
+state == 1 {
+   grp[$1] = ++n
+   sub($1"[][  ]*", "")
+   printf "\tN_(\"%s\"),\n", $0
+}
+/\[common\]/ {
+   state = 1
+}
+END { print "};" }
-- 
2.4.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html