* [PATCH] Documentation: Spelling fix
From: Fredrik Skolmli @ 2008-10-19 16:09 UTC (permalink / raw)
To: gitster; +Cc: git
Signed-off-by: Fredrik Skolmli <fredrik@frsk.net>
---
Documentation/git-checkout.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 2b344e1..ea05a7a 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -88,7 +88,7 @@ This would tell us to use "hack" as the local branch when branching
off of "origin/hack" (or "remotes/origin/hack", or even
"refs/remotes/origin/hack"). If the given name has no slash, or the above
guessing results in an empty name, the guessing is aborted. You can
-exlicitly give a name with '-b' in such a case.
+explicitly give a name with '-b' in such a case.
--no-track::
Ignore the branch.autosetupmerge configuration variable.
--
1.5.6.5
^ permalink raw reply related
* [PATCH v2] Add command line option --chdir/-C to allow setting git process work directory.
From: Maciej Pasternacki @ 2008-10-19 16:18 UTC (permalink / raw)
To: git; +Cc: Jeff King
When "git pull" is ran outside of work tree, it is unable to update work tree
with pulled changes; specifying --git-dir and --work-tree does not help here
because "cd_to_toplevel" call in git-pull occurs after "require_work_tree";
changing order may break the commend if there is no working tree. Some more
commands behave in a similar way.
In my project, I need to call "git pull" from outside of work tree, but I need
it to update the work tree. It seems to require doing chdir() before running
git, but this is problematic thing to do in the calling program because of
portability issues. Proper solution seems to be providing -C / --chdir command
line option, similar to this of Make, that would make main git program perform
chdir() to specified directory before running the specific command. This would
make using git from outside programs much more straightforward.
This patch provides -C and --chdir command line options that behave as
described above.
Signed-off-by: Maciej Pasternacki <maciej@pasternacki.net>
---
Documentation/git.txt | 6 +++++-
git.c | 19 ++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/Documentation/git.txt b/Documentation/git.txt
index df420ae..6676d68 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -12,7 +12,7 @@ SYNOPSIS
'git' [--version] [--exec-path[=GIT_EXEC_PATH]]
[-p|--paginate|--no-pager]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
- [--help] COMMAND [ARGS]
+ [-C DIRECTORY|--chdir=DIRECTORY] [--help] COMMAND [ARGS]
DESCRIPTION
-----------
@@ -185,6 +185,10 @@ help ...`.
environment is not set, it is set to the current working
directory.
+-C <directory>::
+--chdir=<directory>::
+ Change working directory before doing anything.
+
FURTHER DOCUMENTATION
---------------------
diff --git a/git.c b/git.c
index 89feb0b..c63d754 100644
--- a/git.c
+++ b/git.c
@@ -4,7 +4,7 @@
#include "quote.h"
const char git_usage_string[] =
- "git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
+ "git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [-C DIR|--chdir=DIR] [--help] COMMAND [ARGS]";
const char git_more_info_string[] =
"See 'git help COMMAND' for more information on a specific command.";
@@ -115,6 +115,23 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);
if (envchanged)
*envchanged = 1;
+ } else if (!strcmp(cmd, "-C") || !strcmp(cmd, "--chdir")) {
+ if (*argc < 2) {
+ fprintf(stderr, "No directory given for --chdir or -C.\n" );
+ usage(git_usage_string);
+ }
+ if (chdir((*argv)[1])) {
+ fprintf(stderr, "Cannot change directory to %s: %s\n", (*argv)[1], strerror(errno));
+ usage(git_usage_string);
+ }
+ (*argv)++;
+ (*argc)--;
+ handled++;
+ } else if (!prefixcmp(cmd,"--chdir=")) {
+ if (chdir(cmd+8)) {
+ fprintf(stderr, "Cannot change directory to %s: %s\n", cmd+8, strerror(errno));
+ usage(git_usage_string);
+ }
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(git_usage_string);
--
1.6.0.1
^ permalink raw reply related
* Re: [PATCH/RFR&A] Do not rename read-only files during a push
From: Shawn O. Pearce @ 2008-10-19 17:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Petr Baudis, Johannes Sixt, git
In-Reply-To: <7v63np83mw.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> This is on the "merged to 'master' soon" list, but has a small amend by me
> (namely, chmod of final pack is done only when we are writing the final
> pack, i.e. reading from stdin) to fix breakages observed in tests. It
> would be nice to get a final Ack before moving it to 'master'.
Looks fine to me.
> From: Petr Baudis <pasky@suse.cz>
>
> Win32 does not allow renaming read-only files (at least on a Samba
> share), making push into a local directory to fail. Thus, defer
> the chmod() call in index-pack.c:final() only after
> move_temp_to_file() was called.
>
> Signed-off-by: Petr Baudis <pasky@suse.cz>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
> index-pack.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/index-pack.c b/index-pack.c
> index d3a4d31..aec11cb 100644
> --- a/index-pack.c
> +++ b/index-pack.c
> @@ -790,7 +790,6 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
> err = close(output_fd);
> if (err)
> die("error while closing pack file: %s", strerror(errno));
> - chmod(curr_pack_name, 0444);
> }
>
> if (keep_msg) {
> @@ -824,8 +823,9 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
> if (move_temp_to_file(curr_pack_name, final_pack_name))
> die("cannot store pack file");
> }
> + if (from_stdin)
> + chmod(final_pack_name, 0444);
>
> - chmod(curr_index_name, 0444);
> if (final_index_name != curr_index_name) {
> if (!final_index_name) {
> snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
> @@ -835,6 +835,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
> if (move_temp_to_file(curr_index_name, final_index_name))
> die("cannot store index file");
> }
> + chmod(final_index_name, 0444);
>
> if (!from_stdin) {
> printf("%s\n", sha1_to_hex(sha1));
> --
> 1.6.0.2.767.g8f0e
>
--
Shawn.
^ permalink raw reply
* Re: [JGIT PATCH] Encode/decode index and tree entries using UTF-8
From: Shawn O. Pearce @ 2008-10-19 17:14 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <200810191529.43439.robin.rosenberg.lists@dewire.com>
Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
> Decoding uses the same strategy as for commit messages and other string
> entities. Encoding is always done in UTF-8. This is incompatible with
> Git for non-unicode unices, but it leads to the expected behavior on
> Windows and cross-locale sharing of repositories.
FWIW I think this is a good idea.
> Inpired by the recent thread on the gitml, I decideed to clean up jgit a little. I
> know the GitIndex is soon to be obsoleted, but it it still the class that does
> the dirty work when committing in Egit and the changes are fairly simple
> anyway.
Yup, I agree.
I mostly agree with the patch, but we have a utility function you
are missing using:
> @@ -300,11 +302,11 @@ static boolean File_hasExecute() {
> return FS.INSTANCE.supportsExecute();
> }
>
> - static byte[] makeKey(File wd, File f) {
> + static byte[] makeKey(File wd, File f) throws IOException {
> if (!f.getPath().startsWith(wd.getPath()))
> throw new Error("Path is not in working dir");
> String relName = Repository.stripWorkDir(wd, f);
> - return relName.getBytes();
> + return relName.getBytes(Constants.CHARACTER_ENCODING);
> }
Instead of "relName.getBytes(Constants.CHARACTER_ENCODING)" use
"Constants.encode(relName)". Its shorter and faster.
> @@ -591,7 +593,7 @@ public String toString() {
> * @return path name for this entry
> */
> public String getName() {
> - return new String(name);
> + return RawParseUtils.decode(Constants.CHARSET, name, 0, name.length);
Heh. That's actually a common idiom. We probably should add:
String decode(final byte[] arr) {
return decode(Constants.CHARSET, arr, 0, arr.length);
}
to RawParseUtils to make these decode whole array calls easier
to make.
I think you should squash this into your patch, and fix up the
getBytes and decode calls as I noted above before we apply this.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
index cc683d7..913f3ae 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
@@ -42,7 +42,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.ByteBuffer;
import java.util.Arrays;
import org.spearce.jgit.lib.AnyObjectId;
@@ -50,6 +49,7 @@
import org.spearce.jgit.lib.FileMode;
import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.util.NB;
+import org.spearce.jgit.util.RawParseUtils;
/**
* A single file (or stage of a file) in a {@link DirCache}.
@@ -405,7 +405,7 @@ public void setObjectIdFromRaw(final byte[] bs, final int p) {
* returned string.
*/
public String getPathString() {
- return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
+ return RawParseUtils.decode(path);
}
/**
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
index 26b6348..589894a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
@@ -39,7 +39,6 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator;
@@ -251,8 +250,7 @@ ObjectId getObjectId() {
* @return name of the tree. This does not contain any '/' characters.
*/
public String getNameString() {
- final ByteBuffer bb = ByteBuffer.wrap(encodedName);
- return Constants.CHARSET.decode(bb).toString();
+ return RawParseUtils.decode(encodedName);
}
/**
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
index 6c0e339..2519f19 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
@@ -379,6 +379,21 @@ public static PersonIdent parsePersonIdent(final byte[] raw, final int nameB) {
}
/**
+ * Decode a region of the buffer from the default character set (UTF-8).
+ *
+ * If the byte stream cannot be decoded that way, the platform default is
+ * tried and if that too fails, the fail-safe ISO-8859-1 encoding is tried.
+ *
+ * @param buffer
+ * buffer to pull raw bytes from.
+ * @return a string representation of the entire buffer, after decoding the
+ * region through the specified character set.
+ */
+ public static String decode(final byte[] buffer) {
+ return decode(Constants.CHARSET, buffer, 0, buffer.length);
+ }
+
+ /**
* Decode a region of the buffer under the specified character set if possible.
*
* If the byte stream cannot be decoded that way, the platform default is tried
--
Shawn.
^ permalink raw reply related
* Re: [PATCH/RFR&A] Do not rename read-only files during a push
From: Johannes Sixt @ 2008-10-19 17:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Petr Baudis, Shawn O. Pearce
In-Reply-To: <7v63np83mw.fsf@gitster.siamese.dyndns.org>
On Sonntag, 19. Oktober 2008, Junio C Hamano wrote:
> From: Petr Baudis <pasky@suse.cz>
>
> Win32 does not allow renaming read-only files (at least on a Samba
> share), making push into a local directory to fail. Thus, defer
> the chmod() call in index-pack.c:final() only after
> move_temp_to_file() was called.
Concerning the Win32 aspect of this patch:
Acked-by: Johannes Sixt <johannes.sixt@telecom.at>
-- Hannes
^ permalink raw reply
* [PATCH, RFC] diff: add option to show context between close chunks
From: René Scharfe @ 2008-10-19 17:59 UTC (permalink / raw)
To: Git Mailing List; +Cc: Davide Libenzi
This patch adds a new diff option, --inter-chunk-context. It can be
used to show the context in gaps between chunks, thereby creating a
big chunk out of two close chunks, in order to have an unbroken
context, making reviews easier.
With --inter-chunk-context=1, patches have the same number of lines
as without the option, as only the chunk header is replaced by the
context line it was shadowing.
You can use commit b0b44bc7b26c8c4b4221a377ce6ba174b843cb8d in the
git repo to try out this option; there's a chunk in transport.c
which is just one line away from the next. (I found this option
helpful in reviewing my own patch before sending. :)
I think it makes sense to make 1, or even 3, the default for this
option for all commands that create patches intended for human
consumption. The patch keeps the default at 0, though.
There are downsides, of course: values higher than 1 potentially make
the resulting patch longer. More context means a higher probability
of (perhaps unnecessary) merge conflicts.
Comments?
---
Documentation/diff-options.txt | 4 ++
diff.c | 4 ++
diff.h | 1 +
t/t4030-diff-inter-chunk-context.sh | 75 +++++++++++++++++++++++++++++++++++
xdiff/xdiff.h | 1 +
xdiff/xemit.c | 3 +-
6 files changed, 87 insertions(+), 1 deletions(-)
create mode 100755 t/t4030-diff-inter-chunk-context.sh
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index c62b45c..e0c6d8c 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -215,6 +215,10 @@ endif::git-format-patch[]
-w::
Shorthand for "--ignore-all-space".
+--inter-chunk-context=<lines>::
+ Show the context between diff chunks, up to the specified number
+ of lines, thereby fusing chunks that are close to each other.
+
--exit-code::
Make the program exit with codes similar to diff(1).
That is, it exits with 1 if there were differences and
diff --git a/diff.c b/diff.c
index 1c6be89..4a3b486 100644
--- a/diff.c
+++ b/diff.c
@@ -1594,6 +1594,7 @@ static void builtin_diff(const char *name_a,
ecbdata.file = o->file;
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
xecfg.ctxlen = o->context;
+ xecfg.interchunkctxlen = o->interchunkcontext;
xecfg.flags = XDL_EMIT_FUNCNAMES;
if (pe)
xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);
@@ -2677,6 +2678,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->b_prefix = arg + 13;
else if (!strcmp(arg, "--no-prefix"))
options->a_prefix = options->b_prefix = "";
+ else if (opt_arg(arg, '\0', "inter-chunk-context",
+ &options->interchunkcontext))
+ ;
else if (!prefixcmp(arg, "--output=")) {
options->file = fopen(arg + strlen("--output="), "w");
options->close_file = 1;
diff --git a/diff.h b/diff.h
index a49d865..6003024 100644
--- a/diff.h
+++ b/diff.h
@@ -77,6 +77,7 @@ struct diff_options {
const char *a_prefix, *b_prefix;
unsigned flags;
int context;
+ int interchunkcontext;
int break_opt;
int detect_rename;
int skip_stat_unmatch;
diff --git a/t/t4030-diff-inter-chunk-context.sh b/t/t4030-diff-inter-chunk-context.sh
new file mode 100755
index 0000000..448f1b9
--- /dev/null
+++ b/t/t4030-diff-inter-chunk-context.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+test_description='diff chunk merging'
+
+. ./test-lib.sh
+
+f() {
+ i=1
+ echo $1
+ while test $i -le $2
+ do
+ echo $i
+ i=$(expr $i + 1)
+ done
+ echo $3
+}
+
+test_expect_success 'setup' '
+ f a 1 b >f1 &&
+ f a 2 b >f2 &&
+ f a 3 b >f3 &&
+ git add f1 f2 f3 &&
+ git commit -q -m. f1 f2 f3 &&
+ f x 1 y >f1 &&
+ f x 2 y >f2 &&
+ f x 3 y >f3
+'
+
+t() {
+ case "$2" in
+ '') cmd="diff -U$1" ;;
+ *) cmd="diff -U$1 --inter-chunk-context=$2" ;;
+ esac
+ label="$cmd, $3 common $4"
+
+ test_expect_success "$label: count chunks ($5)" "
+ test $(git $cmd f$3 | grep '^@@ ' | wc -l) = $5
+ "
+
+ expected="expected.$1.$3.$5"
+ test -f $expected &&
+ test_expect_success "$label: check output" "
+ git $cmd f$3 >actual &&
+ test_cmp $expected actual
+ "
+}
+
+cat <<EOF >expected.0.1.1 || exit 1
+diff --git a/f1 b/f1
+index f1e80ce..ae397d0 100644
+--- a/f1
++++ b/f1
+@@ -1,3 +1,3 @@
+-a
++x
+ 1
+-b
++y
+EOF
+
+# ctx intrctx common lines chunks
+t 0 '' 1 line 2
+t 0 0 1 line 2
+t 0 1 1 line 1
+t 0 2 1 line 1
+t 0 '' 2 lines 2
+t 0 0 2 lines 2
+t 0 1 2 lines 2
+t 0 2 2 lines 1
+t 1 '' 3 lines 2
+t 1 0 3 lines 2
+t 1 1 3 lines 1
+t 1 2 3 lines 1
+
+test_done
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index deebe02..d8f14e6 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -84,6 +84,7 @@ typedef long (*find_func_t)(const char *line, long line_len, char *buffer, long
typedef struct s_xdemitconf {
long ctxlen;
+ long interchunkctxlen;
unsigned long flags;
find_func_t find_func;
void *find_func_priv;
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index d3d9c84..3bf2581 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -60,9 +60,10 @@ static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *
*/
static xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg) {
xdchange_t *xch, *xchp;
+ long max_common = 2 * xecfg->ctxlen + xecfg->interchunkctxlen;
for (xchp = xscr, xch = xscr->next; xch; xchp = xch, xch = xch->next)
- if (xch->i1 - (xchp->i1 + xchp->chg1) > 2 * xecfg->ctxlen)
+ if (xch->i1 - (xchp->i1 + xchp->chg1) > max_common)
break;
return xchp;
--
1.6.0.2.287.g3791f
^ permalink raw reply related
* [PATCH] Teach/Fix -q/-v to pull/fetch
From: Tuncer Ayaz @ 2008-10-19 18:17 UTC (permalink / raw)
To: git
After fixing clone -q I noticed that pull -q does not do what
it's supposed to do and implemented --quiet/--verbose by
adding it to builtin-merge and fixing two places in builtin-fetch.
I have not touched/adjusted contrib/completion/git-completion.bash
but can take a look if wanted. I think it already needs one or two
adjustments caused by recent --OPTIONS changes in master.
I've tested the following invocations with the below changes applied:
$ git pull
$ git pull -q
$ git pull -v
This is the next attempt trying to incorporate Junio's
suggestions and I'm not sure about the following:
1) having the same option callback function in both modules
2) my adaption of the following two lines from
builtin-fetch.c to the new verbosity option:
if (verbosity == VERBOSE)
transport->verbose = 1;
if (verbosity == QUIET)
transport->verbose = -1;
3) my usage of OPTION_CALLBACK. therefore please
correct me if I did it wrong or my cb fun has an
obvious defect. it may very well have one :)
Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
---
Documentation/merge-options.txt | 8 ++++++++
builtin-fetch.c | 35 +++++++++++++++++++++++++----------
builtin-merge.c | 36 +++++++++++++++++++++++++++++-------
git-pull.sh | 10 ++++++++--
4 files changed, 70 insertions(+), 19 deletions(-)
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 007909a..427cdef 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -1,3 +1,11 @@
+-q::
+--quiet::
+ Operate quietly.
+
+-v::
+--verbose::
+ Be verbose.
+
--stat::
Show a diffstat at the end of the merge. The diffstat is also
controlled by the configuration option merge.stat.
diff --git a/builtin-fetch.c b/builtin-fetch.c
index ee93d3a..717e833 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -22,16 +22,31 @@ enum {
TAGS_SET = 2
};
-static int append, force, keep, update_head_ok, verbose, quiet;
+static int append, force, keep, update_head_ok;
static int tags = TAGS_DEFAULT;
static const char *depth;
static const char *upload_pack;
static struct strbuf default_rla = STRBUF_INIT;
static struct transport *transport;
+static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
+
+static int option_parse_verbosity(const struct option *opt,
+ const char *arg, int unset)
+{
+ if (!strcmp("quiet", opt->long_name))
+ verbosity = QUIET;
+ else if (!strcmp("verbose", opt->long_name))
+ verbosity = VERBOSE;
+ return 0;
+}
static struct option builtin_fetch_options[] = {
- OPT__QUIET(&quiet),
- OPT__VERBOSE(&verbose),
+ { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
+ "operate quietly",
+ PARSE_OPT_NOARG, option_parse_verbosity },
+ { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
+ "be verbose",
+ PARSE_OPT_NOARG, option_parse_verbosity },
OPT_BOOLEAN('a', "append", &append,
"append to .git/FETCH_HEAD instead of overwriting"),
OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
@@ -192,7 +207,6 @@ static int s_update_ref(const char *action,
static int update_local_ref(struct ref *ref,
const char *remote,
- int verbose,
char *display)
{
struct commit *current = NULL, *updated;
@@ -210,7 +224,7 @@ static int update_local_ref(struct ref *ref,
die("object %s not found", sha1_to_hex(ref->new_sha1));
if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
- if (verbose)
+ if (verbosity == VERBOSE)
sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
"[up to date]", REFCOL_WIDTH, remote,
pretty_ref);
@@ -366,18 +380,19 @@ static int store_updated_refs(const char *url, const char *remote_name,
note);
if (ref)
- rc |= update_local_ref(ref, what, verbose, note);
+ rc |= update_local_ref(ref, what, note);
else
sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
SUMMARY_WIDTH, *kind ? kind : "branch",
REFCOL_WIDTH, *what ? what : "HEAD");
if (*note) {
- if (!shown_url) {
+ if (verbosity > QUIET && !shown_url) {
fprintf(stderr, "From %.*s\n",
url_len, url);
shown_url = 1;
}
- fprintf(stderr, " %s\n", note);
+ if (verbosity > QUIET)
+ fprintf(stderr, " %s\n", note);
}
}
fclose(fp);
@@ -622,9 +637,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
remote = remote_get(argv[0]);
transport = transport_get(remote, remote->url[0]);
- if (verbose >= 2)
+ if (verbosity == VERBOSE)
transport->verbose = 1;
- if (quiet)
+ if (verbosity == QUIET)
transport->verbose = -1;
if (upload_pack)
set_option(TRANS_OPT_UPLOADPACK, upload_pack);
diff --git a/builtin-merge.c b/builtin-merge.c
index 5e2b7f1..6966831 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -50,6 +50,7 @@ static unsigned char head[20], stash[20];
static struct strategy **use_strategies;
static size_t use_strategies_nr, use_strategies_alloc;
static const char *branch;
+static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -151,7 +152,23 @@ static int option_parse_n(const struct option *opt,
return 0;
}
+static int option_parse_verbosity(const struct option *opt,
+ const char *arg, int unset)
+{
+ if (!strcmp("quiet", opt->long_name))
+ verbosity = QUIET;
+ else if (!strcmp("verbose", opt->long_name))
+ verbosity = VERBOSE;
+ return 0;
+}
+
static struct option builtin_merge_options[] = {
+ { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
+ "operate quietly",
+ PARSE_OPT_NOARG, option_parse_verbosity },
+ { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
+ "be verbose",
+ PARSE_OPT_NOARG, option_parse_verbosity },
{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,
"do not show a diffstat at the end of the merge",
PARSE_OPT_NOARG, option_parse_n },
@@ -249,7 +266,8 @@ static void restore_state(void)
/* This is called when no merge was necessary. */
static void finish_up_to_date(const char *msg)
{
- printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+ if (verbosity > QUIET)
+ printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
drop_save();
}
@@ -330,14 +348,15 @@ static void finish(const unsigned char *new_head, const char *msg)
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
- printf("%s\n", msg);
+ if (verbosity > QUIET)
+ printf("%s\n", msg);
strbuf_addf(&reflog_message, "%s: %s",
getenv("GIT_REFLOG_ACTION"), msg);
}
if (squash) {
squash_message();
} else {
- if (!merge_msg.len)
+ if (verbosity > QUIET && !merge_msg.len)
printf("No merge message -- not updating HEAD\n");
else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
@@ -871,6 +890,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, builtin_merge_options,
builtin_merge_usage, 0);
+ if (verbosity > QUIET)
+ show_diffstat = 0;
if (squash) {
if (!allow_fast_forward)
@@ -1012,10 +1033,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
- printf("Updating %s..%s\n",
- hex,
- find_unique_abbrev(remoteheads->item->object.sha1,
- DEFAULT_ABBREV));
+ if (verbosity > QUIET)
+ printf("Updating %s..%s\n",
+ hex,
+ find_unique_abbrev(remoteheads->item->object.sha1,
+ DEFAULT_ABBREV));
strbuf_addstr(&msg, "Fast forward");
if (have_message)
strbuf_addstr(&msg,
diff --git a/git-pull.sh b/git-pull.sh
index 75c3610..8e25d44 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -16,6 +16,7 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
+quiet= verbose=
strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
@@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
case "$1" in
+ -q|--quiet)
+ quiet=-q ;;
+ -v|--verbose)
+ verbose=-v ;;
-n|--no-stat|--no-summary)
no_stat=-n ;;
--stat|--summary)
@@ -121,7 +126,7 @@ test true = "$rebase" && {
"refs/remotes/$origin/$reflist" 2>/dev/null)"
}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git fetch --update-head-ok "$@" || exit 1
+git fetch $verbose $quiet --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
-exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
+exec git-merge $quiet $verbose $no_stat $no_commit \
+ $squash $no_ff $log_arg $strategy_args \
"$merge_name" HEAD $merge_head
--
1.6.0.2.GIT
^ permalink raw reply related
* Re: [JGIT PATCH v2] Encode/decode index and tree entries using UTF-8
From: Robin Rosenberg @ 2008-10-19 18:24 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20081019171456.GC14786@spearce.org>
Decoding uses the same strategy as for commit messages and other string
entities. Encoding is always done in UTF-8. This is incompatible with
Git for non-unicode unices, but it leads to the expected behavior on
Windows and cross-locale sharing of repositories.
Signed-off-by: Robin Rosenberg <robin.rosnberg@dewire.com>
---
söndagen den 19 oktober 2008 19.14.56 skrev Shawn O. Pearce:
> Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
> > Decoding uses the same strategy as for commit messages and other string
> > entities. Encoding is always done in UTF-8. This is incompatible with
> > Git for non-unicode unices, but it leads to the expected behavior on
> > Windows and cross-locale sharing of repositories.
>
> FWIW I think this is a good idea.
Ok, so here's the update. We might want to move the encode out of Constants
too as it is no longer a utility for constants.
-- robin
.../src/org/spearce/jgit/lib/GitIndex.java | 27 ++++++++--------
.../src/org/spearce/jgit/lib/Tree.java | 16 ++++-----
.../src/org/spearce/jgit/lib/TreeEntry.java | 14 +++-----
.../src/org/spearce/jgit/util/RawParseUtils.java | 32 ++++++++++++++++++++
4 files changed, 58 insertions(+), 31 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
index 22935ab..bafddef 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
@@ -63,6 +63,7 @@
import org.spearce.jgit.errors.CorruptObjectException;
import org.spearce.jgit.errors.NotSupportedException;
import org.spearce.jgit.util.FS;
+import org.spearce.jgit.util.RawParseUtils;
/**
* A representation of the Git index.
@@ -178,8 +179,9 @@ public Entry add(File wd, File f) throws IOException {
* @param f
* the file whose path shall be removed.
* @return true if such a path was found (and thus removed)
+ * @throws IOException
*/
- public boolean remove(File wd, File f) {
+ public boolean remove(File wd, File f) throws IOException {
byte[] key = makeKey(wd, f);
return entries.remove(key) != null;
}
@@ -300,11 +302,11 @@ static boolean File_hasExecute() {
return FS.INSTANCE.supportsExecute();
}
- static byte[] makeKey(File wd, File f) {
+ static byte[] makeKey(File wd, File f) throws IOException {
if (!f.getPath().startsWith(wd.getPath()))
throw new Error("Path is not in working dir");
String relName = Repository.stripWorkDir(wd, f);
- return relName.getBytes();
+ return Constants.encode(relName);
}
Boolean filemode;
@@ -376,7 +378,7 @@ Entry(TreeEntry f, int stage)
size = -1;
}
sha1 = f.getId();
- name = f.getFullName().getBytes("UTF-8");
+ name = Constants.encode(f.getFullName());
flags = (short) ((stage << 12) | name.length); // TODO: fix flags
}
@@ -580,7 +582,7 @@ private File getFile(File wd) {
}
public String toString() {
- return new String(name) + "/SHA-1(" + sha1.name() + ")/M:"
+ return getName() + "/SHA-1(" + sha1.name() + ")/M:"
+ new Date(ctime / 1000000L) + "/C:"
+ new Date(mtime / 1000000L) + "/d" + dev + "/i" + ino
+ "/m" + Integer.toString(mode, 8) + "/u" + uid + "/g"
@@ -591,7 +593,7 @@ public String toString() {
* @return path name for this entry
*/
public String getName() {
- return new String(name);
+ return RawParseUtils.decode(name);
}
/**
@@ -731,7 +733,7 @@ void readTree(String prefix, Tree t) throws IOException {
readTree(name, (Tree) te);
} else {
Entry e = new Entry(te, 0);
- entries.put(name.getBytes("UTF-8"), e);
+ entries.put(Constants.encode(name), e);
}
}
}
@@ -743,7 +745,7 @@ void readTree(String prefix, Tree t) throws IOException {
* @throws IOException
*/
public Entry addEntry(TreeEntry te) throws IOException {
- byte[] key = te.getFullName().getBytes("UTF-8");
+ byte[] key = Constants.encode(te.getFullName());
Entry e = new Entry(te, 0);
entries.put(key, e);
return e;
@@ -824,8 +826,7 @@ public ObjectId writeTree() throws IOException {
}
while (trees.size() < newName.length) {
if (!current.existsTree(newName[trees.size() - 1])) {
- current = new Tree(current, newName[trees.size() - 1]
- .getBytes());
+ current = new Tree(current, Constants.encode(newName[trees.size() - 1]));
current.getParent().addEntry(current);
trees.push(current);
} else {
@@ -835,7 +836,7 @@ public ObjectId writeTree() throws IOException {
}
}
FileTreeEntry ne = new FileTreeEntry(current, e.sha1,
- newName[newName.length - 1].getBytes(),
+ Constants.encode(newName[newName.length - 1]),
(e.mode & FileMode.EXECUTABLE_FILE.getBits()) == FileMode.EXECUTABLE_FILE.getBits());
current.addEntry(ne);
}
@@ -880,7 +881,7 @@ int longestCommonPath(String[] a, String[] b) {
* Small beware: Unaccounted for are unmerged entries. You may want
* to abort if members with stage != 0 are found if you are doing
* any updating operations. All stages will be found after one another
- * here later. Currently only one stage per name is returned.
+ * here later. Currently only one stage per name is returned.
*
* @return The index entries sorted
*/
@@ -896,7 +897,7 @@ int longestCommonPath(String[] a, String[] b) {
* @throws UnsupportedEncodingException
*/
public Entry getEntry(String path) throws UnsupportedEncodingException {
- return (Entry) entries.get(Repository.gitInternalSlash(path.getBytes("ISO-8859-1")));
+ return (Entry) entries.get(Repository.gitInternalSlash(Constants.encode(path)));
}
/**
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java
index 25a9a71..0ecd04d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java
@@ -44,6 +44,7 @@
import org.spearce.jgit.errors.CorruptObjectException;
import org.spearce.jgit.errors.EntryExistsException;
import org.spearce.jgit.errors.MissingObjectException;
+import org.spearce.jgit.util.RawParseUtils;
/**
* A representation of a Git tree entry. A Tree is a directory in Git.
@@ -251,7 +252,7 @@ public void unload() {
* @throws IOException
*/
public FileTreeEntry addFile(final String name) throws IOException {
- return addFile(Repository.gitInternalSlash(name.getBytes(Constants.CHARACTER_ENCODING)), 0);
+ return addFile(Repository.gitInternalSlash(Constants.encode(name)), 0);
}
/**
@@ -281,8 +282,7 @@ public FileTreeEntry addFile(final byte[] s, final int offset)
final byte[] newName = substring(s, offset, slash);
if (p >= 0)
- throw new EntryExistsException(new String(newName,
- Constants.CHARACTER_ENCODING));
+ throw new EntryExistsException(RawParseUtils.decode(newName));
else if (slash < s.length) {
final Tree t = new Tree(this, newName);
insertEntry(p, t);
@@ -304,7 +304,7 @@ else if (slash < s.length) {
* @throws IOException
*/
public Tree addTree(final String name) throws IOException {
- return addTree(Repository.gitInternalSlash(name.getBytes(Constants.CHARACTER_ENCODING)), 0);
+ return addTree(Repository.gitInternalSlash(Constants.encode(name)), 0);
}
/**
@@ -332,8 +332,7 @@ public Tree addTree(final byte[] s, final int offset) throws IOException {
final byte[] newName = substring(s, offset, slash);
if (p >= 0)
- throw new EntryExistsException(new String(newName,
- Constants.CHARACTER_ENCODING));
+ throw new EntryExistsException(RawParseUtils.decode(newName));
final Tree t = new Tree(this, newName);
insertEntry(p, t);
@@ -355,8 +354,7 @@ public void addEntry(final TreeEntry e) throws IOException {
e.attachParent(this);
insertEntry(p, e);
} else {
- throw new EntryExistsException(new String(e.getNameUTF8(),
- Constants.CHARACTER_ENCODING));
+ throw new EntryExistsException(e.getName());
}
}
@@ -450,7 +448,7 @@ public boolean existsBlob(String path) throws IOException {
}
private TreeEntry findMember(final String s, byte slast) throws IOException {
- return findMember(Repository.gitInternalSlash(s.getBytes(Constants.CHARACTER_ENCODING)), slast, 0);
+ return findMember(Repository.gitInternalSlash(Constants.encode(s)), slast, 0);
}
private TreeEntry findMember(final byte[] s, final byte slast, final int offset)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
index 85dda1d..c95863c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
@@ -39,9 +39,9 @@
package org.spearce.jgit.lib;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import org.spearce.jgit.lib.GitIndex.Entry;
+import org.spearce.jgit.util.RawParseUtils;
/**
* This class represents an entry in a tree, like a blob or another tree.
@@ -126,13 +126,9 @@ public Repository getRepository() {
* @return the name of this entry.
*/
public String getName() {
- try {
- return nameUTF8 != null ? new String(nameUTF8,
- Constants.CHARACTER_ENCODING) : null;
- } catch (UnsupportedEncodingException uee) {
- throw new RuntimeException("JVM doesn't support "
- + Constants.CHARACTER_ENCODING, uee);
- }
+ if (nameUTF8 != null)
+ return RawParseUtils.decode(nameUTF8);
+ return null;
}
/**
@@ -142,7 +138,7 @@ public String getName() {
* @throws IOException
*/
public void rename(final String n) throws IOException {
- rename(n.getBytes(Constants.CHARACTER_ENCODING));
+ rename(Constants.encode(n));
}
/**
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
index 6c0e339..4b96439 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
@@ -379,6 +379,38 @@ public static PersonIdent parsePersonIdent(final byte[] raw, final int nameB) {
}
/**
+ * Decode a buffer under UTF-8, if possible.
+ *
+ * If the byte stream cannot be decoded that way, the platform default is tried
+ * and if that too fails, the fail-safe ISO-8859-1 encoding is tried.
+ *
+ * @param buffer
+ * buffer to pull raw bytes from.
+ * @return a string representation of the range <code>[start,end)</code>,
+ * after decoding the region through the specified character set.
+ */
+ public static String decode(final byte[] buffer) {
+ return decode(Constants.CHARSET, buffer, 0, buffer.length);
+ }
+
+ /**
+ * Decode a buffer under the specified character set if possible.
+ *
+ * If the byte stream cannot be decoded that way, the platform default is tried
+ * and if that too fails, the fail-safe ISO-8859-1 encoding is tried.
+ *
+ * @param cs
+ * character set to use when decoding the buffer.
+ * @param buffer
+ * buffer to pull raw bytes from.
+ * @return a string representation of the range <code>[start,end)</code>,
+ * after decoding the region through the specified character set.
+ */
+ public static String decode(final Charset cs, final byte[] buffer) {
+ return decode(cs, buffer, 0, buffer.length);
+ }
+
+ /**
* Decode a region of the buffer under the specified character set if possible.
*
* If the byte stream cannot be decoded that way, the platform default is tried
--
1.6.0.2.308.gef4a
^ permalink raw reply related
* [PATCH] parse-opt: migrate builtin-checkout-index.
From: Miklos Vajna @ 2008-10-19 18:30 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Pierre Habouzit, git
In-Reply-To: <1224292643-28704-1-git-send-email-vmiklos@frugalware.org>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
On Sat, Oct 18, 2008 at 03:17:23AM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> > This adds a new feature to say --no-z from the command line, doesn't
> > it?
> > And I suspect the feature is broken ;-).
>
> Right, I fixed this in option_parse_z(). --no-z should set
> line_termination to \n instead of 1.
Originally in option_parse_z() I had
line_termination = unset;
which is in fact right, because (as Pierre pointed out) unset for short
options are always false, but I changed it to
line_termination = 0;
to make it more readable.
> > Is this comment still correct? Do the original and your version act
> > the
> > same way when the user says "checkout --stdin -f", for example? I
> > suspect
> > the original refused it and yours take it (and do much more sensible
> > thing), which would be an improvement, but then the error message
> > should
> > be reworded perhaps?
>
> Unless I missed something, that was a limitation of the option parser.
> checkout-index --stdin -f works fine for me after removing those two
> lines, so I left them out from the updated patch.
I still think that check is necessary, but the reasoning was false: what
we need to check is the usage of --stdin and filenames togother. But a
bit later there is a
die("git checkout-index: don't mix '--stdin' and explicit filenames");
so the check I removed was unnecessary.
Here is a patch with the cleaned up option_parse_z().
builtin-checkout-index.c | 149 +++++++++++++++++++++++++---------------------
1 files changed, 80 insertions(+), 69 deletions(-)
diff --git a/builtin-checkout-index.c b/builtin-checkout-index.c
index 4ba2702..2c558dd 100644
--- a/builtin-checkout-index.c
+++ b/builtin-checkout-index.c
@@ -40,6 +40,7 @@
#include "cache.h"
#include "quote.h"
#include "cache-tree.h"
+#include "parse-options.h"
#define CHECKOUT_ALL 4
static int line_termination = '\n';
@@ -153,11 +154,55 @@ static void checkout_all(const char *prefix, int prefix_length)
exit(128);
}
-static const char checkout_cache_usage[] =
-"git checkout-index [-u] [-q] [-a] [-f] [-n] [--stage=[123]|all] [--prefix=<string>] [--temp] [--] <file>...";
+static const char * const builtin_checkout_index_usage[] = {
+ "git checkout-index [options] [--] <file>...",
+ NULL
+};
static struct lock_file lock_file;
+static int option_parse_u(const struct option *opt,
+ const char *arg, int unset)
+{
+ int *newfd = opt->value;
+
+ state.refresh_cache = 1;
+ if (*newfd < 0)
+ *newfd = hold_locked_index(&lock_file, 1);
+ return 0;
+}
+
+static int option_parse_z(const struct option *opt,
+ const char *arg, int unset)
+{
+ line_termination = 0;
+ return 0;
+}
+
+static int option_parse_prefix(const struct option *opt,
+ const char *arg, int unset)
+{
+ state.base_dir = arg;
+ state.base_dir_len = strlen(arg);
+ return 0;
+}
+
+static int option_parse_stage(const struct option *opt,
+ const char *arg, int unset)
+{
+ if (!strcmp(arg, "all")) {
+ to_tempfile = 1;
+ checkout_stage = CHECKOUT_ALL;
+ } else {
+ int ch = arg[0];
+ if ('1' <= ch && ch <= '3')
+ checkout_stage = arg[0] - '0';
+ else
+ die("stage should be between 1 and 3 or all");
+ }
+ return 0;
+}
+
int cmd_checkout_index(int argc, const char **argv, const char *prefix)
{
int i;
@@ -165,6 +210,33 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
int all = 0;
int read_from_stdin = 0;
int prefix_length;
+ int force = 0, quiet = 0, not_new = 0;
+ struct option builtin_checkout_index_options[] = {
+ OPT_BOOLEAN('a', "all", &all,
+ "checks out all files in the index"),
+ OPT_BOOLEAN('f', "force", &force,
+ "forces overwrite of existing files"),
+ OPT__QUIET(&quiet),
+ OPT_BOOLEAN('n', "no-create", ¬_new,
+ "don't checkout new files"),
+ { OPTION_CALLBACK, 'u', "index", &newfd, NULL,
+ "update stat information in the index file",
+ PARSE_OPT_NOARG, option_parse_u },
+ { OPTION_CALLBACK, 'z', NULL, NULL, NULL,
+ "paths are separated with NUL character",
+ PARSE_OPT_NOARG, option_parse_z },
+ OPT_BOOLEAN(0, "stdin", &read_from_stdin,
+ "read list of paths from the standard input"),
+ OPT_BOOLEAN(0, "temp", &to_tempfile,
+ "write the content to temporary files"),
+ OPT_CALLBACK(0, "prefix", NULL, "string",
+ "when creating files, prepend <string>",
+ option_parse_prefix),
+ OPT_CALLBACK(0, "stage", NULL, NULL,
+ "copy out the files from named stage",
+ option_parse_stage),
+ OPT_END()
+ };
git_config(git_default_config, NULL);
state.base_dir = "";
@@ -174,72 +246,11 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
die("invalid cache");
}
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
-
- if (!strcmp(arg, "--")) {
- i++;
- break;
- }
- if (!strcmp(arg, "-a") || !strcmp(arg, "--all")) {
- all = 1;
- continue;
- }
- if (!strcmp(arg, "-f") || !strcmp(arg, "--force")) {
- state.force = 1;
- continue;
- }
- if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet")) {
- state.quiet = 1;
- continue;
- }
- if (!strcmp(arg, "-n") || !strcmp(arg, "--no-create")) {
- state.not_new = 1;
- continue;
- }
- if (!strcmp(arg, "-u") || !strcmp(arg, "--index")) {
- state.refresh_cache = 1;
- if (newfd < 0)
- newfd = hold_locked_index(&lock_file, 1);
- continue;
- }
- if (!strcmp(arg, "-z")) {
- line_termination = 0;
- continue;
- }
- if (!strcmp(arg, "--stdin")) {
- if (i != argc - 1)
- die("--stdin must be at the end");
- read_from_stdin = 1;
- i++; /* do not consider arg as a file name */
- break;
- }
- if (!strcmp(arg, "--temp")) {
- to_tempfile = 1;
- continue;
- }
- if (!prefixcmp(arg, "--prefix=")) {
- state.base_dir = arg+9;
- state.base_dir_len = strlen(state.base_dir);
- continue;
- }
- if (!prefixcmp(arg, "--stage=")) {
- if (!strcmp(arg + 8, "all")) {
- to_tempfile = 1;
- checkout_stage = CHECKOUT_ALL;
- } else {
- int ch = arg[8];
- if ('1' <= ch && ch <= '3')
- checkout_stage = arg[8] - '0';
- else
- die("stage should be between 1 and 3 or all");
- }
- continue;
- }
- if (arg[0] == '-')
- usage(checkout_cache_usage);
- break;
- }
+ argc = parse_options(argc, argv, builtin_checkout_index_options,
+ builtin_checkout_index_usage, 0);
+ state.force = force;
+ state.quiet = quiet;
+ state.not_new = not_new;
if (state.base_dir_len || to_tempfile) {
/* when --prefix is specified we do not
@@ -253,7 +264,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
}
/* Check out named files first */
- for ( ; i < argc; i++) {
+ for (i = 0; i < argc; i++) {
const char *arg = argv[i];
const char *p;
--
1.6.0.2
^ permalink raw reply related
* Re: [PATCH] parse-opt: migrate builtin-checkout-index.
From: Miklos Vajna @ 2008-10-19 18:31 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Pierre Habouzit, git
In-Reply-To: <1224441040-5071-1-git-send-email-vmiklos@frugalware.org>
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
On Sun, Oct 19, 2008 at 08:30:40PM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> I still think that check is necessary, but the reasoning was false: what
^ unnecessary
Sorry for not reading over my mail before sending it.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [PATCH] Teach/Fix -q/-v to pull/fetch
From: Tuncer Ayaz @ 2008-10-19 18:33 UTC (permalink / raw)
To: git
In-Reply-To: <1224440277-2469-1-git-send-email-tuncer.ayaz@gmail.com>
On Sun, Oct 19, 2008 at 8:17 PM, Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
> After fixing clone -q I noticed that pull -q does not do what
> it's supposed to do and implemented --quiet/--verbose by
> adding it to builtin-merge and fixing two places in builtin-fetch.
>
> I have not touched/adjusted contrib/completion/git-completion.bash
> but can take a look if wanted. I think it already needs one or two
> adjustments caused by recent --OPTIONS changes in master.
>
> I've tested the following invocations with the below changes applied:
> $ git pull
> $ git pull -q
> $ git pull -v
>
> This is the next attempt trying to incorporate Junio's
> suggestions and I'm not sure about the following:
> 1) having the same option callback function in both modules
> 2) my adaption of the following two lines from
> builtin-fetch.c to the new verbosity option:
> if (verbosity == VERBOSE)
> transport->verbose = 1;
> if (verbosity == QUIET)
> transport->verbose = -1;
> 3) my usage of OPTION_CALLBACK. therefore please
> correct me if I did it wrong or my cb fun has an
> obvious defect. it may very well have one :)
it doesn't work as I expected when you supply -q and -v.
I have to redo it, I guess.
> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
> ---
> Documentation/merge-options.txt | 8 ++++++++
> builtin-fetch.c | 35 +++++++++++++++++++++++++----------
> builtin-merge.c | 36 +++++++++++++++++++++++++++++-------
> git-pull.sh | 10 ++++++++--
> 4 files changed, 70 insertions(+), 19 deletions(-)
>
> diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
> index 007909a..427cdef 100644
> --- a/Documentation/merge-options.txt
> +++ b/Documentation/merge-options.txt
> @@ -1,3 +1,11 @@
> +-q::
> +--quiet::
> + Operate quietly.
> +
> +-v::
> +--verbose::
> + Be verbose.
> +
> --stat::
> Show a diffstat at the end of the merge. The diffstat is also
> controlled by the configuration option merge.stat.
> diff --git a/builtin-fetch.c b/builtin-fetch.c
> index ee93d3a..717e833 100644
> --- a/builtin-fetch.c
> +++ b/builtin-fetch.c
> @@ -22,16 +22,31 @@ enum {
> TAGS_SET = 2
> };
>
> -static int append, force, keep, update_head_ok, verbose, quiet;
> +static int append, force, keep, update_head_ok;
> static int tags = TAGS_DEFAULT;
> static const char *depth;
> static const char *upload_pack;
> static struct strbuf default_rla = STRBUF_INIT;
> static struct transport *transport;
> +static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
> +
> +static int option_parse_verbosity(const struct option *opt,
> + const char *arg, int unset)
> +{
> + if (!strcmp("quiet", opt->long_name))
> + verbosity = QUIET;
> + else if (!strcmp("verbose", opt->long_name))
> + verbosity = VERBOSE;
> + return 0;
> +}
>
> static struct option builtin_fetch_options[] = {
> - OPT__QUIET(&quiet),
> - OPT__VERBOSE(&verbose),
> + { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
> + "operate quietly",
> + PARSE_OPT_NOARG, option_parse_verbosity },
> + { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
> + "be verbose",
> + PARSE_OPT_NOARG, option_parse_verbosity },
> OPT_BOOLEAN('a', "append", &append,
> "append to .git/FETCH_HEAD instead of overwriting"),
> OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
> @@ -192,7 +207,6 @@ static int s_update_ref(const char *action,
>
> static int update_local_ref(struct ref *ref,
> const char *remote,
> - int verbose,
> char *display)
> {
> struct commit *current = NULL, *updated;
> @@ -210,7 +224,7 @@ static int update_local_ref(struct ref *ref,
> die("object %s not found", sha1_to_hex(ref->new_sha1));
>
> if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
> - if (verbose)
> + if (verbosity == VERBOSE)
> sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
> "[up to date]", REFCOL_WIDTH, remote,
> pretty_ref);
> @@ -366,18 +380,19 @@ static int store_updated_refs(const char *url, const char *remote_name,
> note);
>
> if (ref)
> - rc |= update_local_ref(ref, what, verbose, note);
> + rc |= update_local_ref(ref, what, note);
> else
> sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
> SUMMARY_WIDTH, *kind ? kind : "branch",
> REFCOL_WIDTH, *what ? what : "HEAD");
> if (*note) {
> - if (!shown_url) {
> + if (verbosity > QUIET && !shown_url) {
> fprintf(stderr, "From %.*s\n",
> url_len, url);
> shown_url = 1;
> }
> - fprintf(stderr, " %s\n", note);
> + if (verbosity > QUIET)
> + fprintf(stderr, " %s\n", note);
> }
> }
> fclose(fp);
> @@ -622,9 +637,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
> remote = remote_get(argv[0]);
>
> transport = transport_get(remote, remote->url[0]);
> - if (verbose >= 2)
> + if (verbosity == VERBOSE)
> transport->verbose = 1;
> - if (quiet)
> + if (verbosity == QUIET)
> transport->verbose = -1;
> if (upload_pack)
> set_option(TRANS_OPT_UPLOADPACK, upload_pack);
> diff --git a/builtin-merge.c b/builtin-merge.c
> index 5e2b7f1..6966831 100644
> --- a/builtin-merge.c
> +++ b/builtin-merge.c
> @@ -50,6 +50,7 @@ static unsigned char head[20], stash[20];
> static struct strategy **use_strategies;
> static size_t use_strategies_nr, use_strategies_alloc;
> static const char *branch;
> +static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
>
> static struct strategy all_strategy[] = {
> { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
> @@ -151,7 +152,23 @@ static int option_parse_n(const struct option *opt,
> return 0;
> }
>
> +static int option_parse_verbosity(const struct option *opt,
> + const char *arg, int unset)
> +{
> + if (!strcmp("quiet", opt->long_name))
> + verbosity = QUIET;
> + else if (!strcmp("verbose", opt->long_name))
> + verbosity = VERBOSE;
> + return 0;
> +}
> +
> static struct option builtin_merge_options[] = {
> + { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
> + "operate quietly",
> + PARSE_OPT_NOARG, option_parse_verbosity },
> + { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
> + "be verbose",
> + PARSE_OPT_NOARG, option_parse_verbosity },
> { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
> "do not show a diffstat at the end of the merge",
> PARSE_OPT_NOARG, option_parse_n },
> @@ -249,7 +266,8 @@ static void restore_state(void)
> /* This is called when no merge was necessary. */
> static void finish_up_to_date(const char *msg)
> {
> - printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
> + if (verbosity > QUIET)
> + printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
> drop_save();
> }
>
> @@ -330,14 +348,15 @@ static void finish(const unsigned char *new_head, const char *msg)
> if (!msg)
> strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
> else {
> - printf("%s\n", msg);
> + if (verbosity > QUIET)
> + printf("%s\n", msg);
> strbuf_addf(&reflog_message, "%s: %s",
> getenv("GIT_REFLOG_ACTION"), msg);
> }
> if (squash) {
> squash_message();
> } else {
> - if (!merge_msg.len)
> + if (verbosity > QUIET && !merge_msg.len)
> printf("No merge message -- not updating HEAD\n");
> else {
> const char *argv_gc_auto[] = { "gc", "--auto", NULL };
> @@ -871,6 +890,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>
> argc = parse_options(argc, argv, builtin_merge_options,
> builtin_merge_usage, 0);
> + if (verbosity > QUIET)
> + show_diffstat = 0;
>
> if (squash) {
> if (!allow_fast_forward)
> @@ -1012,10 +1033,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>
> strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
>
> - printf("Updating %s..%s\n",
> - hex,
> - find_unique_abbrev(remoteheads->item->object.sha1,
> - DEFAULT_ABBREV));
> + if (verbosity > QUIET)
> + printf("Updating %s..%s\n",
> + hex,
> + find_unique_abbrev(remoteheads->item->object.sha1,
> + DEFAULT_ABBREV));
> strbuf_addstr(&msg, "Fast forward");
> if (have_message)
> strbuf_addstr(&msg,
> diff --git a/git-pull.sh b/git-pull.sh
> index 75c3610..8e25d44 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -16,6 +16,7 @@ cd_to_toplevel
> test -z "$(git ls-files -u)" ||
> die "You are in the middle of a conflicted merge."
>
> +quiet= verbose=
> strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
> curr_branch=$(git symbolic-ref -q HEAD)
> curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
> @@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
> while :
> do
> case "$1" in
> + -q|--quiet)
> + quiet=-q ;;
> + -v|--verbose)
> + verbose=-v ;;
> -n|--no-stat|--no-summary)
> no_stat=-n ;;
> --stat|--summary)
> @@ -121,7 +126,7 @@ test true = "$rebase" && {
> "refs/remotes/$origin/$reflist" 2>/dev/null)"
> }
> orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
> -git fetch --update-head-ok "$@" || exit 1
> +git fetch $verbose $quiet --update-head-ok "$@" || exit 1
>
> curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
> if test "$curr_head" != "$orig_head"
> @@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
> test true = "$rebase" &&
> exec git-rebase $strategy_args --onto $merge_head \
> ${oldremoteref:-$merge_head}
> -exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
> +exec git-merge $quiet $verbose $no_stat $no_commit \
> + $squash $no_ff $log_arg $strategy_args \
> "$merge_name" HEAD $merge_head
> --
> 1.6.0.2.GIT
>
>
^ permalink raw reply
* Re: [PATCH] Teach/Fix -q/-v to pull/fetch
From: Tuncer Ayaz @ 2008-10-19 18:37 UTC (permalink / raw)
To: git
In-Reply-To: <4ac8254d0810191133v79ed73b7tf09a282f44d302dd@mail.gmail.com>
On Sun, Oct 19, 2008 at 8:33 PM, Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
> On Sun, Oct 19, 2008 at 8:17 PM, Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
>> After fixing clone -q I noticed that pull -q does not do what
>> it's supposed to do and implemented --quiet/--verbose by
>> adding it to builtin-merge and fixing two places in builtin-fetch.
>>
>> I have not touched/adjusted contrib/completion/git-completion.bash
>> but can take a look if wanted. I think it already needs one or two
>> adjustments caused by recent --OPTIONS changes in master.
>>
>> I've tested the following invocations with the below changes applied:
>> $ git pull
>> $ git pull -q
>> $ git pull -v
>>
>> This is the next attempt trying to incorporate Junio's
>> suggestions and I'm not sure about the following:
>> 1) having the same option callback function in both modules
>> 2) my adaption of the following two lines from
>> builtin-fetch.c to the new verbosity option:
>> if (verbosity == VERBOSE)
>> transport->verbose = 1;
>> if (verbosity == QUIET)
>> transport->verbose = -1;
>> 3) my usage of OPTION_CALLBACK. therefore please
>> correct me if I did it wrong or my cb fun has an
>> obvious defect. it may very well have one :)
>
> it doesn't work as I expected when you supply -q and -v.
> I have to redo it, I guess.
Junio, what do you think?
if I call "git pull -q -v" or "git pull -v -q" verbosity will be VERBOSE.
is that ok or should I make sure that the last one overrides
verbosity?
>> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>> ---
>> Documentation/merge-options.txt | 8 ++++++++
>> builtin-fetch.c | 35 +++++++++++++++++++++++++----------
>> builtin-merge.c | 36 +++++++++++++++++++++++++++++-------
>> git-pull.sh | 10 ++++++++--
>> 4 files changed, 70 insertions(+), 19 deletions(-)
>>
>> diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
>> index 007909a..427cdef 100644
>> --- a/Documentation/merge-options.txt
>> +++ b/Documentation/merge-options.txt
>> @@ -1,3 +1,11 @@
>> +-q::
>> +--quiet::
>> + Operate quietly.
>> +
>> +-v::
>> +--verbose::
>> + Be verbose.
>> +
>> --stat::
>> Show a diffstat at the end of the merge. The diffstat is also
>> controlled by the configuration option merge.stat.
>> diff --git a/builtin-fetch.c b/builtin-fetch.c
>> index ee93d3a..717e833 100644
>> --- a/builtin-fetch.c
>> +++ b/builtin-fetch.c
>> @@ -22,16 +22,31 @@ enum {
>> TAGS_SET = 2
>> };
>>
>> -static int append, force, keep, update_head_ok, verbose, quiet;
>> +static int append, force, keep, update_head_ok;
>> static int tags = TAGS_DEFAULT;
>> static const char *depth;
>> static const char *upload_pack;
>> static struct strbuf default_rla = STRBUF_INIT;
>> static struct transport *transport;
>> +static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
>> +
>> +static int option_parse_verbosity(const struct option *opt,
>> + const char *arg, int unset)
>> +{
>> + if (!strcmp("quiet", opt->long_name))
>> + verbosity = QUIET;
>> + else if (!strcmp("verbose", opt->long_name))
>> + verbosity = VERBOSE;
>> + return 0;
>> +}
>>
>> static struct option builtin_fetch_options[] = {
>> - OPT__QUIET(&quiet),
>> - OPT__VERBOSE(&verbose),
>> + { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
>> + "operate quietly",
>> + PARSE_OPT_NOARG, option_parse_verbosity },
>> + { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
>> + "be verbose",
>> + PARSE_OPT_NOARG, option_parse_verbosity },
>> OPT_BOOLEAN('a', "append", &append,
>> "append to .git/FETCH_HEAD instead of overwriting"),
>> OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
>> @@ -192,7 +207,6 @@ static int s_update_ref(const char *action,
>>
>> static int update_local_ref(struct ref *ref,
>> const char *remote,
>> - int verbose,
>> char *display)
>> {
>> struct commit *current = NULL, *updated;
>> @@ -210,7 +224,7 @@ static int update_local_ref(struct ref *ref,
>> die("object %s not found", sha1_to_hex(ref->new_sha1));
>>
>> if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
>> - if (verbose)
>> + if (verbosity == VERBOSE)
>> sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
>> "[up to date]", REFCOL_WIDTH, remote,
>> pretty_ref);
>> @@ -366,18 +380,19 @@ static int store_updated_refs(const char *url, const char *remote_name,
>> note);
>>
>> if (ref)
>> - rc |= update_local_ref(ref, what, verbose, note);
>> + rc |= update_local_ref(ref, what, note);
>> else
>> sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
>> SUMMARY_WIDTH, *kind ? kind : "branch",
>> REFCOL_WIDTH, *what ? what : "HEAD");
>> if (*note) {
>> - if (!shown_url) {
>> + if (verbosity > QUIET && !shown_url) {
>> fprintf(stderr, "From %.*s\n",
>> url_len, url);
>> shown_url = 1;
>> }
>> - fprintf(stderr, " %s\n", note);
>> + if (verbosity > QUIET)
>> + fprintf(stderr, " %s\n", note);
>> }
>> }
>> fclose(fp);
>> @@ -622,9 +637,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
>> remote = remote_get(argv[0]);
>>
>> transport = transport_get(remote, remote->url[0]);
>> - if (verbose >= 2)
>> + if (verbosity == VERBOSE)
>> transport->verbose = 1;
>> - if (quiet)
>> + if (verbosity == QUIET)
>> transport->verbose = -1;
>> if (upload_pack)
>> set_option(TRANS_OPT_UPLOADPACK, upload_pack);
>> diff --git a/builtin-merge.c b/builtin-merge.c
>> index 5e2b7f1..6966831 100644
>> --- a/builtin-merge.c
>> +++ b/builtin-merge.c
>> @@ -50,6 +50,7 @@ static unsigned char head[20], stash[20];
>> static struct strategy **use_strategies;
>> static size_t use_strategies_nr, use_strategies_alloc;
>> static const char *branch;
>> +static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
>>
>> static struct strategy all_strategy[] = {
>> { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
>> @@ -151,7 +152,23 @@ static int option_parse_n(const struct option *opt,
>> return 0;
>> }
>>
>> +static int option_parse_verbosity(const struct option *opt,
>> + const char *arg, int unset)
>> +{
>> + if (!strcmp("quiet", opt->long_name))
>> + verbosity = QUIET;
>> + else if (!strcmp("verbose", opt->long_name))
>> + verbosity = VERBOSE;
>> + return 0;
>> +}
>> +
>> static struct option builtin_merge_options[] = {
>> + { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
>> + "operate quietly",
>> + PARSE_OPT_NOARG, option_parse_verbosity },
>> + { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
>> + "be verbose",
>> + PARSE_OPT_NOARG, option_parse_verbosity },
>> { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
>> "do not show a diffstat at the end of the merge",
>> PARSE_OPT_NOARG, option_parse_n },
>> @@ -249,7 +266,8 @@ static void restore_state(void)
>> /* This is called when no merge was necessary. */
>> static void finish_up_to_date(const char *msg)
>> {
>> - printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
>> + if (verbosity > QUIET)
>> + printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
>> drop_save();
>> }
>>
>> @@ -330,14 +348,15 @@ static void finish(const unsigned char *new_head, const char *msg)
>> if (!msg)
>> strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
>> else {
>> - printf("%s\n", msg);
>> + if (verbosity > QUIET)
>> + printf("%s\n", msg);
>> strbuf_addf(&reflog_message, "%s: %s",
>> getenv("GIT_REFLOG_ACTION"), msg);
>> }
>> if (squash) {
>> squash_message();
>> } else {
>> - if (!merge_msg.len)
>> + if (verbosity > QUIET && !merge_msg.len)
>> printf("No merge message -- not updating HEAD\n");
>> else {
>> const char *argv_gc_auto[] = { "gc", "--auto", NULL };
>> @@ -871,6 +890,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>>
>> argc = parse_options(argc, argv, builtin_merge_options,
>> builtin_merge_usage, 0);
>> + if (verbosity > QUIET)
>> + show_diffstat = 0;
>>
>> if (squash) {
>> if (!allow_fast_forward)
>> @@ -1012,10 +1033,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>>
>> strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
>>
>> - printf("Updating %s..%s\n",
>> - hex,
>> - find_unique_abbrev(remoteheads->item->object.sha1,
>> - DEFAULT_ABBREV));
>> + if (verbosity > QUIET)
>> + printf("Updating %s..%s\n",
>> + hex,
>> + find_unique_abbrev(remoteheads->item->object.sha1,
>> + DEFAULT_ABBREV));
>> strbuf_addstr(&msg, "Fast forward");
>> if (have_message)
>> strbuf_addstr(&msg,
>> diff --git a/git-pull.sh b/git-pull.sh
>> index 75c3610..8e25d44 100755
>> --- a/git-pull.sh
>> +++ b/git-pull.sh
>> @@ -16,6 +16,7 @@ cd_to_toplevel
>> test -z "$(git ls-files -u)" ||
>> die "You are in the middle of a conflicted merge."
>>
>> +quiet= verbose=
>> strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
>> curr_branch=$(git symbolic-ref -q HEAD)
>> curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
>> @@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
>> while :
>> do
>> case "$1" in
>> + -q|--quiet)
>> + quiet=-q ;;
>> + -v|--verbose)
>> + verbose=-v ;;
>> -n|--no-stat|--no-summary)
>> no_stat=-n ;;
>> --stat|--summary)
>> @@ -121,7 +126,7 @@ test true = "$rebase" && {
>> "refs/remotes/$origin/$reflist" 2>/dev/null)"
>> }
>> orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
>> -git fetch --update-head-ok "$@" || exit 1
>> +git fetch $verbose $quiet --update-head-ok "$@" || exit 1
>>
>> curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
>> if test "$curr_head" != "$orig_head"
>> @@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
>> test true = "$rebase" &&
>> exec git-rebase $strategy_args --onto $merge_head \
>> ${oldremoteref:-$merge_head}
>> -exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
>> +exec git-merge $quiet $verbose $no_stat $no_commit \
>> + $squash $no_ff $log_arg $strategy_args \
>> "$merge_name" HEAD $merge_head
>> --
>> 1.6.0.2.GIT
>>
>>
>
^ permalink raw reply
* Re: Usability of git stash
From: Shawn O. Pearce @ 2008-10-19 18:40 UTC (permalink / raw)
To: Anders Melchiorsen; +Cc: Brandon Casey, David Kastrup, git
In-Reply-To: <87prly5k5r.fsf@cup.kalibalik.dk>
Anders Melchiorsen <mail@cup.kalibalik.dk> wrote:
> Brandon Casey <casey@nrlssc.navy.mil> writes:
>
> > In exchange for allowing new users to stub their toe on new commands, the
> > work flow of more experienced users is made a little easier.
>
> I wonder whether experienced users even use stash a lot. Personally,
> after getting my head around the DAG, and thus getting more
> comfortable with git reset, I tend to make "WIP" commits instead.
Ditto. I never use "git stash". Its command line usage is too
unfriendly for me, so I tend to prefer making WIP commits. If I
need to stash something I'll do:
git commit -a -m wip
... some time later ..
git checkout branch
git reset --soft HEAD^
> The primary thing that stash does for me is preserve the index state.
> Unfortunately, --index is not default for stash apply, so I often
> forget it.
I never find the index saving useful. My commits are frequent
enough that losing the index state usually only costs me a few
minutes when I go back to the branch and pop the wip commit.
> Sometimes, I also want stash to store away changes to untracked files
> (to get a clean working directory), but that is not possible.
Indeed, that's an advantage of the wip commit approach, you can shove
the untracked files quickly into the wip commit, especially with 1.6:
git commit -A -m wip
Personally I wish git-stash wasn't invented the way it is. I would
have rather seen it as macros to do a quick:
git commit -m wip-index-state
git commit -A -m wip-worktree-state
and unwind it with essentially:
git reset --mixed HEAD^
git reset --soft HEAD^
then its a lot less black magic to users, as they can see it in the
DAG, and its more explicitly tied to the branch they were on at the
time they ran the stash. I think its rare you'd stash something
then switch to another branch to apply it. But that could easily
be done with cherry-pick.
--
Shawn.
^ permalink raw reply
* [PATCH stgit] revised patch for importing series from tarball
From: Clark Williams @ 2008-10-19 19:16 UTC (permalink / raw)
To: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 1057 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Catalin,
Attached is my revised patch (v2 I believe) for importing a series directly from a tarball. I looked at the critique offered by Karl (pretty hard actually), but I decided in the end to keep extracting the tarball to a temp directory. It's possible that it would be desirable to extract members directly from a tarball (although as far as I can tell, you still have to extract them to a file) but I didn't judge the churn in imprt.py to be worth it for now. This version is pretty simple, in that you just detect that the input to to import_series is a tarball, call import_tarfile, then return.
I added a simple test to the test harness for import as well.
Oh and I added '*.elc' to the .gitignore file. May not be that many folks using emacs with stgit, but hey, I am! :)
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
iEYEARECAAYFAkj7h4QACgkQqA4JVb61b9dq4ACbB9tl0FbHq5igNIPIbzALhyLf
Aw8An3weTNye7yzQ/wU2Hyt1agzCzTtC
=7WjV
-----END PGP SIGNATURE-----
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tarfiles.patch --]
[-- Type: text/x-patch; name=tarfiles.patch, Size: 13375 bytes --]
patch to allow importing a series from a tar archive
From: Clark Williams <williams@redhat.com>
Signed-off-by: Clark Williams <williams@redhat.com>
---
.gitignore | 1
stgit/commands/imprt.py | 47 ++++++++++++++++++++++-
t/t1800-import.sh | 12 ++++++
t/t1800-import/patches/attribution.patch | 21 ++++++++++
| 22 +++++++++++
t/t1800-import/patches/fifth-stanza.patch | 22 +++++++++++
t/t1800-import/patches/first-stanza.patch | 18 +++++++++
t/t1800-import/patches/fourth-stanza.patch | 22 +++++++++++
t/t1800-import/patches/second-stanza.patch | 22 +++++++++++
t/t1800-import/patches/series | 10 +++++
t/t1800-import/patches/seventh-stanza.patch | 24 ++++++++++++
t/t1800-import/patches/sixth-stanza.patch | 22 +++++++++++
t/t1800-import/patches/third-stanza.patch | 22 +++++++++++
13 files changed, 263 insertions(+), 2 deletions(-)
create mode 100644 t/t1800-import/patches/attribution.patch
create mode 100644 t/t1800-import/patches/delete-extra-lines.patch
create mode 100644 t/t1800-import/patches/fifth-stanza.patch
create mode 100644 t/t1800-import/patches/first-stanza.patch
create mode 100644 t/t1800-import/patches/fourth-stanza.patch
create mode 100644 t/t1800-import/patches/second-stanza.patch
create mode 100644 t/t1800-import/patches/series
create mode 100644 t/t1800-import/patches/seventh-stanza.patch
create mode 100644 t/t1800-import/patches/sixth-stanza.patch
create mode 100644 t/t1800-import/patches/third-stanza.patch
diff --git a/.gitignore b/.gitignore
index 91dbad2..f0e5d30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ patches-*
release.sh
setup.cfg.rpm
snapshot.sh
+*.elc
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 227743f..6860d0e 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -19,6 +19,7 @@ import sys, os, re, email
from mailbox import UnixMailbox
from StringIO import StringIO
from optparse import OptionParser, make_option
+import tarfile
from stgit.commands.common import *
from stgit.utils import *
@@ -52,7 +53,7 @@ options = [make_option('-m', '--mail',
help = 'import a series of patches from an mbox file',
action = 'store_true'),
make_option('-s', '--series',
- help = 'import a series of patches',
+ help = 'import a series of patches from a series file or a tar archive',
action = 'store_true'),
make_option('-u', '--url',
help = 'import a patch from a URL',
@@ -87,7 +88,7 @@ options = [make_option('-m', '--mail',
make_option('--commname',
help = 'use COMMNAME as the committer name'),
make_option('--commemail',
- help = 'use COMMEMAIL as the committer e-mail')
+ help = 'use COMMEMAIL as the committer e-mail'),
] + make_sign_options()
@@ -234,6 +235,9 @@ def __import_series(filename, options):
applied = crt_series.get_applied()
if filename:
+ if tarfile.is_tarfile(filename):
+ __import_tarfile(filename, options)
+ return
f = file(filename)
patchdir = os.path.dirname(filename)
else:
@@ -287,6 +291,45 @@ def __import_url(url, options):
urllib.urlretrieve(url, filename)
__import_file(filename, options)
+def __import_tarfile(tar, options):
+ """Import patch series from a tar archive
+ """
+ import tempfile
+ import shutil
+
+ if not tarfile.is_tarfile(tar):
+ raise CmdException, "%s is not a tarfile!" % tar
+
+
+ t = tarfile.open(tar, 'r')
+ names = t.getnames()
+
+ # verify paths in the tarfile are safe
+ for n in names:
+ if n.startswith('/'):
+ raise CmdException, "Absolute path found in %s" % tar
+ if n.find("..") > -1:
+ raise CmdException, "Relative path found in %s" % tar
+
+ # find the series file
+ seriesfile = '';
+ for m in names:
+ if m.endswith('/series') or m == 'series':
+ seriesfile = m
+ break
+ if seriesfile == '':
+ raise CmdException, "no 'series' file found in %s" % tar
+
+ # unpack into a tmp dir
+ tmpdir = tempfile.mkdtemp('.stg')
+ t.extractall(tmpdir)
+
+ # apply the series
+ __import_series(os.path.join(tmpdir, seriesfile), options)
+
+ # cleanup the tmpdir
+ shutil.rmtree(tmpdir)
+
def func(parser, options, args):
"""Import a GNU diff file as a new patch
"""
diff --git a/t/t1800-import.sh b/t/t1800-import.sh
index 1352743..5a3384f 100755
--- a/t/t1800-import.sh
+++ b/t/t1800-import.sh
@@ -122,4 +122,16 @@ test_expect_success \
stg delete ..
'
+test_expect_success \
+ 'apply a series from a tarball' \
+ '
+ rm -f jabberwocky.txt && touch jabberwocky.txt &&
+ git add jabberwocky.txt && git commit -m "empty file" jabberwocky.txt &&
+ (cd ../t1800-import; tar -cjf jabberwocky.tar.bz2 patches) &&
+ stg import --series ../t1800-import/jabberwocky.tar.bz2
+ [ $(git cat-file -p $(stg id) \
+ | grep -c "tree 2c33937252a21f1550c0bf21f1de534b68f69635") = 1 ] &&
+ rm ../t1800-import/jabberwocky.tar.bz2
+ '
+
test_done
diff --git a/t/t1800-import/patches/attribution.patch b/t/t1800-import/patches/attribution.patch
new file mode 100644
index 0000000..2b7c8f9
--- /dev/null
+++ b/t/t1800-import/patches/attribution.patch
@@ -0,0 +1,21 @@
+attribution
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index 066d2e8..a9dd1f3 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -32,3 +32,7 @@ O frabjous day! Callooh! Callay!'
+ Did gyre and gimble in the wabe;
+ All mimsy were the borogoves,
+ And the mome raths outgrabe.
++
++ JABBERWOCKY
++ Lewis Carroll
++ (from Through the Looking-Glass and What Alice Found There, 1872)
--git a/t/t1800-import/patches/delete-extra-lines.patch b/t/t1800-import/patches/delete-extra-lines.patch
new file mode 100644
index 0000000..e5b7a65
--- /dev/null
+++ b/t/t1800-import/patches/delete-extra-lines.patch
@@ -0,0 +1,22 @@
+delete extra lines
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 2 --
+ 1 files changed, 0 insertions(+), 2 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index 98cb716..066d2e8 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -28,8 +28,6 @@ He left it dead, and with its head
+ O frabjous day! Callooh! Callay!'
+ He chortled in his joy.
+
+-
+-
+ `Twas brillig, and the slithy toves
+ Did gyre and gimble in the wabe;
+ All mimsy were the borogoves,
diff --git a/t/t1800-import/patches/fifth-stanza.patch b/t/t1800-import/patches/fifth-stanza.patch
new file mode 100644
index 0000000..4f0e77c
--- /dev/null
+++ b/t/t1800-import/patches/fifth-stanza.patch
@@ -0,0 +1,22 @@
+fifth stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index b1c2ad3..f1416dc 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -17,3 +17,8 @@ And, as in uffish thought he stood,
+ The Jabberwock, with eyes of flame,
+ Came whiffling through the tulgey wood,
+ And burbled as it came!
++
++One, two! One, two! And through and through
++ The vorpal blade went snicker-snack!
++He left it dead, and with its head
++ He went galumphing back.
diff --git a/t/t1800-import/patches/first-stanza.patch b/t/t1800-import/patches/first-stanza.patch
new file mode 100644
index 0000000..ee7818f
--- /dev/null
+++ b/t/t1800-import/patches/first-stanza.patch
@@ -0,0 +1,18 @@
+first stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index e69de29..fba24dc 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -0,0 +1,4 @@
++`Twas brillig, and the slithy toves
++ Did gyre and gimble in the wabe:
++All mimsy were the borogoves,
++ And the mome raths outgrabe.
diff --git a/t/t1800-import/patches/fourth-stanza.patch b/t/t1800-import/patches/fourth-stanza.patch
new file mode 100644
index 0000000..eb2f8f2
--- /dev/null
+++ b/t/t1800-import/patches/fourth-stanza.patch
@@ -0,0 +1,22 @@
+fourth stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index 6405f36..b1c2ad3 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -12,3 +12,8 @@ He took his vorpal sword in hand:
+ Long time the manxome foe he sought --
+ So rested he by the Tumtum tree,
+ And stood awhile in thought.
++
++And, as in uffish thought he stood,
++ The Jabberwock, with eyes of flame,
++Came whiffling through the tulgey wood,
++ And burbled as it came!
diff --git a/t/t1800-import/patches/second-stanza.patch b/t/t1800-import/patches/second-stanza.patch
new file mode 100644
index 0000000..bec1622
--- /dev/null
+++ b/t/t1800-import/patches/second-stanza.patch
@@ -0,0 +1,22 @@
+second stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index fba24dc..9ed0b49 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -2,3 +2,8 @@
+ Did gyre and gimble in the wabe:
+ All mimsy were the borogoves,
+ And the mome raths outgrabe.
++
++"Beware the Jabberwock, my son!
++ The jaws that bite, the claws that catch!
++Beware the Jubjub bird, and shun
++ The frumious Bandersnatch!"
diff --git a/t/t1800-import/patches/series b/t/t1800-import/patches/series
new file mode 100644
index 0000000..5945c98
--- /dev/null
+++ b/t/t1800-import/patches/series
@@ -0,0 +1,10 @@
+# This series applies on GIT commit 6a8b6f6e2ecbcab26de7656b66b7f30eeba1ee96
+first-stanza.patch
+second-stanza.patch
+third-stanza.patch
+fourth-stanza.patch
+fifth-stanza.patch
+sixth-stanza.patch
+seventh-stanza.patch
+delete-extra-lines.patch
+attribution.patch
diff --git a/t/t1800-import/patches/seventh-stanza.patch b/t/t1800-import/patches/seventh-stanza.patch
new file mode 100644
index 0000000..555c200
--- /dev/null
+++ b/t/t1800-import/patches/seventh-stanza.patch
@@ -0,0 +1,24 @@
+seventh stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 7 +++++++
+ 1 files changed, 7 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index bf732f5..98cb716 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -27,3 +27,10 @@ He left it dead, and with its head
+ Come to my arms, my beamish boy!
+ O frabjous day! Callooh! Callay!'
+ He chortled in his joy.
++
++
++
++`Twas brillig, and the slithy toves
++ Did gyre and gimble in the wabe;
++All mimsy were the borogoves,
++ And the mome raths outgrabe.
diff --git a/t/t1800-import/patches/sixth-stanza.patch b/t/t1800-import/patches/sixth-stanza.patch
new file mode 100644
index 0000000..2349b7e
--- /dev/null
+++ b/t/t1800-import/patches/sixth-stanza.patch
@@ -0,0 +1,22 @@
+sixth stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index f1416dc..bf732f5 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -22,3 +22,8 @@ One, two! One, two! And through and through
+ The vorpal blade went snicker-snack!
+ He left it dead, and with its head
+ He went galumphing back.
++
++"And, has thou slain the Jabberwock?
++ Come to my arms, my beamish boy!
++O frabjous day! Callooh! Callay!'
++ He chortled in his joy.
diff --git a/t/t1800-import/patches/third-stanza.patch b/t/t1800-import/patches/third-stanza.patch
new file mode 100644
index 0000000..d942353
--- /dev/null
+++ b/t/t1800-import/patches/third-stanza.patch
@@ -0,0 +1,22 @@
+third stanza
+
+From: Clark Williams <williams@redhat.com>
+
+
+---
+ jabberwocky.txt | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/jabberwocky.txt b/jabberwocky.txt
+index 9ed0b49..6405f36 100644
+--- a/jabberwocky.txt
++++ b/jabberwocky.txt
+@@ -7,3 +7,8 @@ All mimsy were the borogoves,
+ The jaws that bite, the claws that catch!
+ Beware the Jubjub bird, and shun
+ The frumious Bandersnatch!"
++
++He took his vorpal sword in hand:
++ Long time the manxome foe he sought --
++So rested he by the Tumtum tree,
++ And stood awhile in thought.
^ permalink raw reply related
* Re: [PATCH] parse-opt: migrate builtin-checkout-index.
From: Raphael Zimmerer @ 2008-10-19 19:29 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Junio C Hamano, Pierre Habouzit, git
In-Reply-To: <1224292643-28704-1-git-send-email-vmiklos@frugalware.org>
On Sat, Oct 18, 2008 at 03:17:23AM +0200, Miklos Vajna wrote:
> Right, I fixed this in option_parse_z(). --no-z should set
> line_termination to \n instead of 1.
How about "--no-null"?
The long option name for "-z" is "--null", as used in git-config and
git-grep. So I suggest to use that as the long option name for "-z",
as the enhanced option parser automatically will recongnize
"--no-null", when used. That helps avoid further confusion with git
option names.
- Raphael
^ permalink raw reply
* Re: [PATCH] parse-opt: migrate builtin-checkout-index.
From: Pierre Habouzit @ 2008-10-19 19:34 UTC (permalink / raw)
To: Raphael Zimmerer; +Cc: Miklos Vajna, Junio C Hamano, git
In-Reply-To: <20081019192906.GA26073@rdrz.de>
[-- Attachment #1: Type: text/plain, Size: 872 bytes --]
On Sun, Oct 19, 2008 at 07:29:08PM +0000, Raphael Zimmerer wrote:
> On Sat, Oct 18, 2008 at 03:17:23AM +0200, Miklos Vajna wrote:
> > Right, I fixed this in option_parse_z(). --no-z should set
> > line_termination to \n instead of 1.
>
> How about "--no-null"?
>
> The long option name for "-z" is "--null", as used in git-config and
> git-grep. So I suggest to use that as the long option name for "-z",
> as the enhanced option parser automatically will recongnize
> "--no-null", when used. That helps avoid further confusion with git
> option names.
git checkout-index has no --null option. If you make --null be the long
form for -z then --no-null will be "autogenerated".
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: Detached checkout will clobber branch head when using symlink HEAD
From: Junio C Hamano @ 2008-10-19 19:36 UTC (permalink / raw)
To: Jeff King; +Cc: Matt Draisey, git
In-Reply-To: <20081019130050.GA1822@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> But if I am reading your patch right, you are actually enabling detached
> HEAD in this instance, which is much better. Unfortunately, I had quite
> a few conflicts in applying your patches on top of master (with or
> without the patch from "checkout --track -b broken"), and when I thought
> I had fixed up the result, the test actually still failed.
>
> So I will take your word that it actually works, and that I screwed up
> resolving the conflicts.
It's the three-patch series that leads to 684968c (Fix checkout not to
clobber the branch when using symlinked HEAD upon detaching, 2008-10-17).
> PS If you are rebasing or resolving anyway, as I suspect you will have
> to, there is a typo in the test: s/detch/detach/
Thanks; the series was only in 'pu', so I will.
^ permalink raw reply
* [PATCH] Teach/Fix pull/fetch -q/-v options
From: Tuncer Ayaz @ 2008-10-19 19:48 UTC (permalink / raw)
To: git; +Cc: gitster
After fixing clone -q I noticed that pull -q does not do what
it's supposed to do and implemented --quiet/--verbose by
adding it to builtin-merge and fixing two places in builtin-fetch.
I have not touched/adjusted contrib/completion/git-completion.bash
but can take a look if wanted. I think it already needs one or two
adjustments caused by recent --OPTIONS changes in master.
I've tested the following invocations with the below changes applied:
$ git pull
$ git pull -q
$ git pull -v
This is the next attempt trying to incorporate Junio's
suggestions and I'm not sure about the following:
1) having the same option callback function in both modules
2) my adaption of the following two lines from
builtin-fetch.c to the new verbosity option:
if (verbosity == VERBOSE)
transport->verbose = 1;
if (verbosity == QUIET)
transport->verbose = -1;
3) my usage of OPTION_CALLBACK
4) my support for overriding -q or -v
as implemented in git-pull.sh by appending
-q or -v as it is passed to the script
therefore please correct me if I did it wrong or my
cb fun has an obvious defect. it may very well
have one :)
This revision does actually override verbosity
based on what was supplied later in argv (-q or -v).
Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
---
Documentation/merge-options.txt | 8 +++++++
builtin-fetch.c | 39 ++++++++++++++++++++++++++++---------
builtin-merge.c | 40 ++++++++++++++++++++++++++++++++------
git-pull.sh | 10 +++++++-
4 files changed, 78 insertions(+), 19 deletions(-)
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 007909a..427cdef 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -1,3 +1,11 @@
+-q::
+--quiet::
+ Operate quietly.
+
+-v::
+--verbose::
+ Be verbose.
+
--stat::
Show a diffstat at the end of the merge. The diffstat is also
controlled by the configuration option merge.stat.
diff --git a/builtin-fetch.c b/builtin-fetch.c
index ee93d3a..2596aee 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -22,16 +22,35 @@ enum {
TAGS_SET = 2
};
-static int append, force, keep, update_head_ok, verbose, quiet;
+static int append, force, keep, update_head_ok;
static int tags = TAGS_DEFAULT;
static const char *depth;
static const char *upload_pack;
static struct strbuf default_rla = STRBUF_INIT;
static struct transport *transport;
+static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
+
+static int option_parse_quiet(const struct option *opt,
+ const char *arg, int unset)
+{
+ verbosity = QUIET;
+ return 0;
+}
+
+static int option_parse_verbose(const struct option *opt,
+ const char *arg, int unset)
+{
+ verbosity = VERBOSE;
+ return 0;
+}
static struct option builtin_fetch_options[] = {
- OPT__QUIET(&quiet),
- OPT__VERBOSE(&verbose),
+ { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
+ "operate quietly",
+ PARSE_OPT_NOARG, option_parse_quiet },
+ { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
+ "be verbose",
+ PARSE_OPT_NOARG, option_parse_verbose },
OPT_BOOLEAN('a', "append", &append,
"append to .git/FETCH_HEAD instead of overwriting"),
OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
@@ -192,7 +211,6 @@ static int s_update_ref(const char *action,
static int update_local_ref(struct ref *ref,
const char *remote,
- int verbose,
char *display)
{
struct commit *current = NULL, *updated;
@@ -210,7 +228,7 @@ static int update_local_ref(struct ref *ref,
die("object %s not found", sha1_to_hex(ref->new_sha1));
if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
- if (verbose)
+ if (verbosity == VERBOSE)
sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
"[up to date]", REFCOL_WIDTH, remote,
pretty_ref);
@@ -366,18 +384,19 @@ static int store_updated_refs(const char *url, const char *remote_name,
note);
if (ref)
- rc |= update_local_ref(ref, what, verbose, note);
+ rc |= update_local_ref(ref, what, note);
else
sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
SUMMARY_WIDTH, *kind ? kind : "branch",
REFCOL_WIDTH, *what ? what : "HEAD");
if (*note) {
- if (!shown_url) {
+ if (verbosity > QUIET && !shown_url) {
fprintf(stderr, "From %.*s\n",
url_len, url);
shown_url = 1;
}
- fprintf(stderr, " %s\n", note);
+ if (verbosity > QUIET)
+ fprintf(stderr, " %s\n", note);
}
}
fclose(fp);
@@ -622,9 +641,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
remote = remote_get(argv[0]);
transport = transport_get(remote, remote->url[0]);
- if (verbose >= 2)
+ if (verbosity == VERBOSE)
transport->verbose = 1;
- if (quiet)
+ if (verbosity == QUIET)
transport->verbose = -1;
if (upload_pack)
set_option(TRANS_OPT_UPLOADPACK, upload_pack);
diff --git a/builtin-merge.c b/builtin-merge.c
index 5e2b7f1..8259acb 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -50,6 +50,7 @@ static unsigned char head[20], stash[20];
static struct strategy **use_strategies;
static size_t use_strategies_nr, use_strategies_alloc;
static const char *branch;
+static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;
static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -151,7 +152,27 @@ static int option_parse_n(const struct option *opt,
return 0;
}
+static int option_parse_quiet(const struct option *opt,
+ const char *arg, int unset)
+{
+ verbosity = QUIET;
+ return 0;
+}
+
+static int option_parse_verbose(const struct option *opt,
+ const char *arg, int unset)
+{
+ verbosity = VERBOSE;
+ return 0;
+}
+
static struct option builtin_merge_options[] = {
+ { OPTION_CALLBACK, 'q', "quiet", NULL, NULL,
+ "operate quietly",
+ PARSE_OPT_NOARG, option_parse_quiet },
+ { OPTION_CALLBACK, 'v', "verbose", NULL, NULL,
+ "be verbose",
+ PARSE_OPT_NOARG, option_parse_verbose },
{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,
"do not show a diffstat at the end of the merge",
PARSE_OPT_NOARG, option_parse_n },
@@ -249,7 +270,8 @@ static void restore_state(void)
/* This is called when no merge was necessary. */
static void finish_up_to_date(const char *msg)
{
- printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+ if (verbosity > QUIET)
+ printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
drop_save();
}
@@ -330,14 +352,15 @@ static void finish(const unsigned char *new_head, const char *msg)
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
- printf("%s\n", msg);
+ if (verbosity > QUIET)
+ printf("%s\n", msg);
strbuf_addf(&reflog_message, "%s: %s",
getenv("GIT_REFLOG_ACTION"), msg);
}
if (squash) {
squash_message();
} else {
- if (!merge_msg.len)
+ if (verbosity > QUIET && !merge_msg.len)
printf("No merge message -- not updating HEAD\n");
else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
@@ -871,6 +894,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, builtin_merge_options,
builtin_merge_usage, 0);
+ if (verbosity > QUIET)
+ show_diffstat = 0;
if (squash) {
if (!allow_fast_forward)
@@ -1012,10 +1037,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
- printf("Updating %s..%s\n",
- hex,
- find_unique_abbrev(remoteheads->item->object.sha1,
- DEFAULT_ABBREV));
+ if (verbosity > QUIET)
+ printf("Updating %s..%s\n",
+ hex,
+ find_unique_abbrev(remoteheads->item->object.sha1,
+ DEFAULT_ABBREV));
strbuf_addstr(&msg, "Fast forward");
if (have_message)
strbuf_addstr(&msg,
diff --git a/git-pull.sh b/git-pull.sh
index 75c3610..dc613db 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -16,6 +16,7 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
+verbosity=
strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
@@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
case "$1" in
+ -q|--quiet)
+ verbosity="$verbosity -q" ;;
+ -v|--verbose)
+ verbosity="$verbosity -v" ;;
-n|--no-stat|--no-summary)
no_stat=-n ;;
--stat|--summary)
@@ -121,7 +126,7 @@ test true = "$rebase" && {
"refs/remotes/$origin/$reflist" 2>/dev/null)"
}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git fetch --update-head-ok "$@" || exit 1
+git fetch $verbosity --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
-exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
+exec git-merge $verbosity $no_stat $no_commit \
+ $squash $no_ff $log_arg $strategy_args \
"$merge_name" HEAD $merge_head
--
1.6.0.2.GIT
^ permalink raw reply related
* Moving a 5 person dev team from CVS to git
From: Francis Galiegue @ 2008-10-19 19:27 UTC (permalink / raw)
To: git
Hello,
I work for a software company with a dev team of 5, and right now a CVS
repository is used for all the code which covers 8 years of history among 52
modules and 1.6 GB data.
All devs use Eclipse, and its featureful CVS plugin. As for myself, I also
write to the CVS tree, but in a CVS-to-git-to-CVS cycle (I don't use Eclipse
but command line). I have talked about git, shown some of its capabilities,
and my boss agreed to give it a shot, but with the following conditions:
* it must provide CVS access (branching and tagging included), as a transition
measure;
* there must be an Eclipse plugin.
I have successfully imported all CVS modules into an equivalent number of git
repositories so far. Unfortunately, I have two problems:
* the git-cvsserver does not support branching and tagging;
* I have successfully built the Eclipse plugin (Java 6, Eclipse 3.4), but am
unable to make it clone a repository and see it in a project, despite quite a
few hours googling around (it _does_ clone, I see the repo in the workspace;
but it's invisible within Eclipse).
Is branching and tagging support a planned feature for git-cvsserver? Also, is
there a step-by-step guide on using egit to clone an existing repository?
(I'm a total beginner with Eclipse, so it may well be that I need to google
some more.)
Thanks,
--
fge
^ permalink raw reply
* Re: [PATCH v2] Fix testcase failure when extended attributes are in use
From: Junio C Hamano @ 2008-10-19 19:59 UTC (permalink / raw)
To: Deskin Miller; +Cc: git, heikki.orsila
In-Reply-To: <20081019122419.GA2015@riemann.deskinm.fdns.net>
Deskin Miller <deskinm@umich.edu> writes:
> My patch, on the other hand, is to deal with 'ls' output in case a file has
> certain filesystem extended attributes. These could be e.g. POSIX ACLs, or a
> SELinux security context, or perhaps others. If such an extended attribute is
> present, 'ls -l' will print permissions with a '+' appended, e.g.
> -rw-r--r--+
> Instead of
> -rw-r--r--
> ...
> For what it's worth, I've experienced this failure on my Ubuntu 8.04 laptop
> with SELinux permissive mode, so it's possible ls behaves slightly differently
> on other systems; I've not been able to determine this one way or another.
Is there way to explicitly tell "ls -l" not to do this, I have to wonder?
POSIX.1 says that the file mode written under the -l option is
"%c%s%s%s%c" (where the first %c is for type, three %s are for owner,
group and other perm, and the last %c is "optional alternate access method
flag"). If there is no alternate or additional access control method
associated with the file, the "optional alternate access method flag"
would be a single SP, otherwise it would be a printable character.
If we drop the default ACL from the trash directory like Matt's patch
does, does a file created in there (i.e. the ones we check with /bin/ls)
still have "alternate or additional access control method associated with"
it?
Somehow it feels wrong that you need your patch, but if you do, stripping
only the trailing '+' as your patch does not look sufficient, either.
Shouldn't we be stripping the last letter if the length of actual is
longer than strlen("-rwxrwxrwx"), as any printable can come there?
t/t1301-shared-repo.sh | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git c/t/t1301-shared-repo.sh i/t/t1301-shared-repo.sh
index 2275caa..653362b 100755
--- c/t/t1301-shared-repo.sh
+++ i/t/t1301-shared-repo.sh
@@ -20,6 +20,10 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '
test $ret != "0"
'
+modebits () {
+ ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
+}
+
for u in 002 022
do
test_expect_success "shared=1 does not clear bits preset by umask $u" '
@@ -85,8 +89,7 @@ do
rm -f .git/info/refs &&
git update-server-info &&
- actual="$(ls -l .git/info/refs)" &&
- actual=${actual%% *} &&
+ actual="$(modebits .git/info/refs)" &&
test "x$actual" = "x-$y" || {
ls -lt .git/info
false
@@ -98,8 +101,7 @@ do
rm -f .git/info/refs &&
git update-server-info &&
- actual="$(ls -l .git/info/refs)" &&
- actual=${actual%% *} &&
+ actual="$(modebits .git/info/refs)" &&
test "x$actual" = "x-$x" || {
ls -lt .git/info
false
^ permalink raw reply related
* Re: [RFC PATCH v3] Documentation: add manpage about workflows
From: Junio C Hamano @ 2008-10-19 20:07 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, santi, Dmitry Potapov
In-Reply-To: <1224429622-1548-1-git-send-email-trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> This attempts to make a manpage about workflows that is both handy to
> point people at it and as a beginner's introduction.
Is this still "RFC PATCH" or meant for application?
I did not find many things that I find objectionable. On the other hand,
I am not a good person to judge if this documentation is easily
understandable by beginners (anymore). Do others who interact regularly
with new people have comments?
^ permalink raw reply
* Re: [PATCH] parse-opt: migrate builtin-checkout-index.
From: Junio C Hamano @ 2008-10-19 20:11 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Pierre Habouzit, git
In-Reply-To: <1224441040-5071-1-git-send-email-vmiklos@frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> writes:
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
>
> On Sat, Oct 18, 2008 at 03:17:23AM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
>> > This adds a new feature to say --no-z from the command line, doesn't
>> > it?
>> > And I suspect the feature is broken ;-).
>>
>> Right, I fixed this in option_parse_z(). --no-z should set
>> line_termination to \n instead of 1.
>
> Originally in option_parse_z() I had
>
> line_termination = unset;
>
> which is in fact right, because (as Pierre pointed out) unset for short
> options are always false, but I changed it to
>
> line_termination = 0;
>
> to make it more readable.
I think Pierre's comment is short-sighted. Think of what would happen
when somebody adds "--nul" as a longer equivalent to "-z", since it is
extremely easy to do things like that with the use of parse-opt API?
^ permalink raw reply
* Re: [PATCH] parse-opt: migrate builtin-checkout-index.
From: Pierre Habouzit @ 2008-10-19 20:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Miklos Vajna, git
In-Reply-To: <7vabd073bg.fsf@gitster.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 1509 bytes --]
On Sun, Oct 19, 2008 at 08:11:31PM +0000, Junio C Hamano wrote:
> Miklos Vajna <vmiklos@frugalware.org> writes:
>
> > Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> > ---
> >
> > On Sat, Oct 18, 2008 at 03:17:23AM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> >> > This adds a new feature to say --no-z from the command line, doesn't
> >> > it?
> >> > And I suspect the feature is broken ;-).
> >>
> >> Right, I fixed this in option_parse_z(). --no-z should set
> >> line_termination to \n instead of 1.
> >
> > Originally in option_parse_z() I had
> >
> > line_termination = unset;
> >
> > which is in fact right, because (as Pierre pointed out) unset for short
> > options are always false, but I changed it to
> >
> > line_termination = 0;
> >
> > to make it more readable.
>
> I think Pierre's comment is short-sighted. Think of what would happen
> when somebody adds "--nul" as a longer equivalent to "-z", since it is
> extremely easy to do things like that with the use of parse-opt API?
Err I was only pointing out that --no-z would no nothing, I actually
didn't really read the argument :) I didn't say having --null was a bad
idea, and I think we have -z/--null at a couple of places already, and
it's probably a good thing to actually _add_ --null.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: Moving a 5 person dev team from CVS to git
From: Shawn O. Pearce @ 2008-10-19 20:20 UTC (permalink / raw)
To: Francis Galiegue; +Cc: git
In-Reply-To: <200810192127.55954.fg@one2team.net>
Francis Galiegue <fg@one2team.net> wrote:
>
> I have successfully imported all CVS modules into an equivalent number of git
> repositories so far. Unfortunately, I have two problems:
>
> * the git-cvsserver does not support branching and tagging;
> * I have successfully built the Eclipse plugin (Java 6, Eclipse 3.4), but am
> unable to make it clone a repository and see it in a project, despite quite a
> few hours googling around (it _does_ clone, I see the repo in the workspace;
> but it's invisible within Eclipse).
After a clone is complete you need to import the projects from your
the directory you cloned into. File->Import; General->Existing
projects; select the directory in your workspace where the repo
is housed, or just select your workspace and let Eclipse search
recursively for the projects.
We'd like to support automatically importing the projects after
the clone is complete, but thus far we haven't put the effort into
restarting the import wizard UI after the download is done.
> Is branching and tagging support a planned feature for git-cvsserver?
No. Nor is it likely to ever get added. Development on
git-cvsserver is stalled as the code is complete enough for anyone
who actively uses it today. Patches for it are welcome if you are
willing to take over development and maintenance of it. But its
more-or-less frozen at this point.
> Also, is
> there a step-by-step guide on using egit to clone an existing repository?
> (I'm a total beginner with Eclipse, so it may well be that I need to google
> some more.)
No, not yet. You could try adding it to the egit wiki page(s):
http://git.or.cz/gitwiki/EclipsePlugin
--
Shawn.
^ permalink raw reply
* Re: [PATCH] parse-opt: migrate builtin-checkout-index.
From: Junio C Hamano @ 2008-10-19 20:59 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: Miklos Vajna, git
In-Reply-To: <20081019201934.GO16610@artemis.corp>
Pierre Habouzit <madcoder@debian.org> writes:
> On Sun, Oct 19, 2008 at 08:11:31PM +0000, Junio C Hamano wrote:
>> Miklos Vajna <vmiklos@frugalware.org> writes:
>
>> >> Right, I fixed this in option_parse_z(). --no-z should set
>> >> line_termination to \n instead of 1.
>> >
>> > Originally in option_parse_z() I had
>> >
>> > line_termination = unset;
>> >
>> > which is in fact right, because (as Pierre pointed out) unset for short
>> > options are always false, but I changed it to
>> >
>> > line_termination = 0;
>> >
>> > to make it more readable.
>>
>> I think Pierre's comment is short-sighted. Think of what would happen
>> when somebody adds "--nul" as a longer equivalent to "-z", since it is
>> extremely easy to do things like that with the use of parse-opt API?
>
> Err I was only pointing out that --no-z would no nothing, I actually
> didn't really read the argument :) I didn't say having --null was a bad
> idea,...
It is a good practice to anticipate potential future breakages, assess the
cost to avoid them, avoid the ones that can be avoided with minimum cost
(and document the others you know will be broken). That's the key to
produce maintainable piece of code. The change necessary to Miklos's
original code to do this is quite simple (i.e. flip between '\0' and
'\n'), and I didn't see any room for argument like "short option won't let
you say --no-z". That's where my comment about "short-sighted"-ness comes
from.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox