* [PATCH v5.1 5/6] Implement 'git checkout --patch'
From: Thomas Rast @ 2009-08-15 11:48 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Sverre Rabbelier, Nanako Shiraishi,
Nicolas Sebrecht, Pierre Habouzit
In-Reply-To: <b75f4adebf7f417b8c46746202933e8f7ff80331.1250164190.git.trast@student.ethz.ch>
This introduces a --patch mode for git-checkout. In the index usage
git checkout --patch -- [files...]
it lets the user discard edits from the <files> at the granularity of
hunks (by selecting hunks from 'git diff' and then reverse applying
them to the worktree).
We also accept a revision argument. In the case
git checkout --patch HEAD -- [files...]
we offer hunks from the difference between HEAD and the worktree, and
reverse applies them to both index and worktree, allowing you to
discard staged changes completely. In the non-HEAD usage
git checkout --patch <revision> -- [files...]
it offers hunks from the difference between the worktree and
<revision>. The chosen hunks are then applied to both index and
worktree.
The application to worktree and index is done "atomically" in the
sense that we first check if the patch applies to the index (it should
always apply to the worktree). If it does not, we give the user a
choice to either abort or apply to the worktree anyway.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
I found another mismatch of the -R flags during double checking, as
follows:
diff --git c/git-add--interactive.perl i/git-add--interactive.perl
index 2363a77..21746d5 100755
--- c/git-add--interactive.perl
+++ i/git-add--interactive.perl
@@ -117,7 +117,7 @@
'checkout_head' => {
DIFF => 'diff-index -p',
APPLY => sub { apply_patch_for_checkout_commit '-R', @_ },
- APPLY_CHECK => 'apply',
+ APPLY_CHECK => 'apply -R',
VERB => 'Discard',
TARGET => ' from index and worktree',
PARTICIPLE => 'discarding',
Documentation/git-checkout.txt | 13 +++++-
builtin-checkout.c | 19 +++++++
git-add--interactive.perl | 61 +++++++++++++++++++++++
t/t2015-checkout-patch.sh | 107 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 199 insertions(+), 1 deletions(-)
create mode 100755 t/t2015-checkout-patch.sh
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index ad4b31e..26a5447 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -11,6 +11,7 @@ SYNOPSIS
'git checkout' [-q] [-f] [-m] [<branch>]
'git checkout' [-q] [-f] [-m] [-b <new_branch>] [<start_point>]
'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
+'git checkout' --patch [<tree-ish>] [--] [<paths>...]
DESCRIPTION
-----------
@@ -25,7 +26,7 @@ use the --track or --no-track options, which will be passed to `git
branch`. As a convenience, --track without `-b` implies branch
creation; see the description of --track below.
-When <paths> are given, this command does *not* switch
+When <paths> or --patch are given, this command does *not* switch
branches. It updates the named paths in the working tree from
the index file, or from a named <tree-ish> (most often a commit). In
this case, the `-b` and `--track` options are meaningless and giving
@@ -113,6 +114,16 @@ the conflicted merge in the specified paths.
"merge" (default) and "diff3" (in addition to what is shown by
"merge" style, shows the original contents).
+-p::
+--patch::
+ Interactively select hunks in the difference between the
+ <tree-ish> (or the index, if unspecified) and the working
+ tree. The chosen hunks are then applied in reverse to the
+ working tree (and if a <tree-ish> was specified, the index).
++
+This means that you can use `git checkout -p` to selectively discard
+edits from your current working tree.
+
<branch>::
Branch to checkout; if it refers to a branch (i.e., a name that,
when prepended with "refs/heads/", is a valid ref), then that
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 8a9a474..8b942ba 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -572,6 +572,13 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
return git_xmerge_config(var, value, cb);
}
+static int interactive_checkout(const char *revision, const char **pathspec,
+ struct checkout_opts *opts)
+{
+ return run_add_interactive(revision, "--patch=checkout", pathspec);
+}
+
+
int cmd_checkout(int argc, const char **argv, const char *prefix)
{
struct checkout_opts opts;
@@ -580,6 +587,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
struct branch_info new;
struct tree *source_tree = NULL;
char *conflict_style = NULL;
+ int patch_mode = 0;
struct option options[] = {
OPT__QUIET(&opts.quiet),
OPT_STRING('b', NULL, &opts.new_branch, "new branch", "branch"),
@@ -594,6 +602,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN('m', "merge", &opts.merge, "merge"),
OPT_STRING(0, "conflict", &conflict_style, "style",
"conflict style (merge or diff3)"),
+ OPT_BOOLEAN('p', "patch", &patch_mode, "select hunks interactively"),
OPT_END(),
};
int has_dash_dash;
@@ -608,6 +617,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options, checkout_usage,
PARSE_OPT_KEEP_DASHDASH);
+ if (patch_mode && (opts.track > 0 || opts.new_branch
+ || opts.new_branch_log || opts.merge || opts.force))
+ die ("--patch is incompatible with all other options");
+
/* --track without -b should DWIM */
if (0 < opts.track && !opts.new_branch) {
const char *argv0 = argv[0];
@@ -714,6 +727,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
if (!pathspec)
die("invalid path specification");
+ if (patch_mode)
+ return interactive_checkout(new.name, pathspec, &opts);
+
/* Checkout paths */
if (opts.new_branch) {
if (argc == 1) {
@@ -729,6 +745,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
return checkout_paths(source_tree, pathspec, &opts);
}
+ if (patch_mode)
+ return interactive_checkout(new.name, NULL, &opts);
+
if (opts.new_branch) {
struct strbuf buf = STRBUF_INIT;
if (strbuf_check_branch_ref(&buf, opts.new_branch))
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index d14f48c..21746d5 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -75,6 +75,7 @@
my $patch_mode_revision;
sub apply_patch;
+sub apply_patch_for_checkout_commit;
my %patch_modes = (
'stage' => {
@@ -104,6 +105,33 @@
PARTICIPLE => 'applying',
FILTER => 'index-only',
},
+ 'checkout_index' => {
+ DIFF => 'diff-files -p',
+ APPLY => sub { apply_patch 'apply -R', @_; },
+ APPLY_CHECK => 'apply -R',
+ VERB => 'Discard',
+ TARGET => ' from worktree',
+ PARTICIPLE => 'discarding',
+ FILTER => 'file-only',
+ },
+ 'checkout_head' => {
+ DIFF => 'diff-index -p',
+ APPLY => sub { apply_patch_for_checkout_commit '-R', @_ },
+ APPLY_CHECK => 'apply -R',
+ VERB => 'Discard',
+ TARGET => ' from index and worktree',
+ PARTICIPLE => 'discarding',
+ FILTER => undef,
+ },
+ 'checkout_nothead' => {
+ DIFF => 'diff-index -R -p',
+ APPLY => sub { apply_patch_for_checkout_commit '', @_ },
+ APPLY_CHECK => 'apply',
+ VERB => 'Apply',
+ TARGET => ' to index and worktree',
+ PARTICIPLE => 'applying',
+ FILTER => undef,
+ },
);
my %patch_mode_flavour = %{$patch_modes{stage}};
@@ -1069,6 +1097,29 @@
return $ret;
}
+sub apply_patch_for_checkout_commit {
+ my $reverse = shift;
+ my $applies_index = run_git_apply 'apply '.$reverse.' --cached --recount --check', @_;
+ my $applies_worktree = run_git_apply 'apply '.$reverse.' --recount --check', @_;
+
+ if ($applies_worktree && $applies_index) {
+ run_git_apply 'apply '.$reverse.' --cached --recount', @_;
+ run_git_apply 'apply '.$reverse.' --recount', @_;
+ return 1;
+ } elsif (!$applies_index) {
+ print colored $error_color, "The selected hunks do not apply to the index!\n";
+ if (prompt_yesno "Apply them to the worktree anyway? ") {
+ return run_git_apply 'apply '.$reverse.' --recount', @_;
+ } else {
+ print colored $error_color, "Nothing was applied.\n";
+ return 0;
+ }
+ } else {
+ print STDERR @_;
+ return 0;
+ }
+}
+
sub patch_update_cmd {
my @all_mods = list_modified($patch_mode_flavour{FILTER});
my @mods = grep { !($_->{BINARY}) } @all_mods;
@@ -1432,6 +1483,16 @@
'reset_head' : 'reset_nothead');
$arg = shift @ARGV or die "missing --";
}
+ } elsif ($1 eq 'checkout') {
+ $arg = shift @ARGV or die "missing --";
+ if ($arg eq '--') {
+ $patch_mode = 'checkout_index';
+ } else {
+ $patch_mode_revision = $arg;
+ $patch_mode = ($arg eq 'HEAD' ?
+ 'checkout_head' : 'checkout_nothead');
+ $arg = shift @ARGV or die "missing --";
+ }
} elsif ($1 eq 'stage') {
$patch_mode = 'stage';
$arg = shift @ARGV or die "missing --";
diff --git a/t/t2015-checkout-patch.sh b/t/t2015-checkout-patch.sh
new file mode 100755
index 0000000..4d1c2e9
--- /dev/null
+++ b/t/t2015-checkout-patch.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+test_description='git checkout --patch'
+
+. ./lib-patch-mode.sh
+
+test_expect_success 'setup' '
+ mkdir dir &&
+ echo parent > dir/foo &&
+ echo dummy > bar &&
+ git add bar dir/foo &&
+ git commit -m initial &&
+ test_tick &&
+ test_commit second dir/foo head &&
+ set_and_save_state bar bar_work bar_index &&
+ save_head
+'
+
+# note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
+
+test_expect_success 'saying "n" does nothing' '
+ set_and_save_state dir/foo work head &&
+ (echo n; echo n) | git checkout -p &&
+ verify_saved_state bar &&
+ verify_saved_state dir/foo
+'
+
+test_expect_success 'git checkout -p' '
+ (echo n; echo y) | git checkout -p &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head
+'
+
+test_expect_success 'git checkout -p with staged changes' '
+ set_state dir/foo work index
+ (echo n; echo y) | git checkout -p &&
+ verify_saved_state bar &&
+ verify_state dir/foo index index
+'
+
+test_expect_success 'git checkout -p HEAD with NO staged changes: abort' '
+ set_and_save_state dir/foo work head &&
+ (echo n; echo y; echo n) | git checkout -p HEAD &&
+ verify_saved_state bar &&
+ verify_saved_state dir/foo
+'
+
+test_expect_success 'git checkout -p HEAD with NO staged changes: apply' '
+ (echo n; echo y; echo y) | git checkout -p HEAD &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head
+'
+
+test_expect_success 'git checkout -p HEAD with change already staged' '
+ set_state dir/foo index index
+ # the third n is to get out in case it mistakenly does not apply
+ (echo n; echo y; echo n) | git checkout -p HEAD &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head
+'
+
+test_expect_success 'git checkout -p HEAD^' '
+ # the third n is to get out in case it mistakenly does not apply
+ (echo n; echo y; echo n) | git checkout -p HEAD^ &&
+ verify_saved_state bar &&
+ verify_state dir/foo parent parent
+'
+
+# The idea in the rest is that bar sorts first, so we always say 'y'
+# first and if the path limiter fails it'll apply to bar instead of
+# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
+# the failure case (and thus get out of the loop).
+
+test_expect_success 'path limiting works: dir' '
+ set_state dir/foo work head &&
+ (echo y; echo n) | git checkout -p dir &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head
+'
+
+test_expect_success 'path limiting works: -- dir' '
+ set_state dir/foo work head &&
+ (echo y; echo n) | git checkout -p -- dir &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head
+'
+
+test_expect_success 'path limiting works: HEAD^ -- dir' '
+ # the third n is to get out in case it mistakenly does not apply
+ (echo y; echo n; echo n) | git checkout -p HEAD^ -- dir &&
+ verify_saved_state bar &&
+ verify_state dir/foo parent parent
+'
+
+test_expect_success 'path limiting works: foo inside dir' '
+ set_state dir/foo work head &&
+ # the third n is to get out in case it mistakenly does not apply
+ (echo y; echo n; echo n) | (cd dir && git checkout -p foo) &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head
+'
+
+test_expect_success 'none of this moved HEAD' '
+ verify_saved_head
+'
+
+test_done
--
1.6.4.287.g3e02d
^ permalink raw reply related
* [PATCH v5.1 4/6] Implement 'git reset --patch'
From: Thomas Rast @ 2009-08-15 11:48 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Sverre Rabbelier, Nanako Shiraishi,
Nicolas Sebrecht, Pierre Habouzit
In-Reply-To: <f3b8fdbcf451fe28786ed221d02717e28423e6dd.1250164190.git.trast@student.ethz.ch>
This introduces a --patch mode for git-reset. The basic case is
git reset --patch -- [files...]
which acts as the opposite of 'git add --patch -- [files...]': it
offers hunks for *un*staging. Advanced usage is
git reset --patch <revision> -- [files...]
which offers hunks from the diff between the index and <revision> for
forward application to the index. (That is, the basic case is just
<revision> = HEAD.)
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Jeff noticed the prompt and patch direction weren't matching:
http://article.gmane.org/gmane.comp.version-control.git/125981
This flips the direction of the patch in the 'git reset -p other'
case, as I really wanted it that way around.
Documentation/git-reset.txt | 15 ++++++++-
builtin-reset.c | 19 ++++++++++++
git-add--interactive.perl | 57 +++++++++++++++++++++++++++++++++--
t/t7105-reset-patch.sh | 69 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 154 insertions(+), 6 deletions(-)
create mode 100755 t/t7105-reset-patch.sh
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index abb25d1..469cf6d 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -10,6 +10,7 @@ SYNOPSIS
[verse]
'git reset' [--mixed | --soft | --hard | --merge] [-q] [<commit>]
'git reset' [-q] [<commit>] [--] <paths>...
+'git reset' --patch [<commit>] [--] [<paths>...]
DESCRIPTION
-----------
@@ -23,8 +24,9 @@ the undo in the history.
If you want to undo a commit other than the latest on a branch,
linkgit:git-revert[1] is your friend.
-The second form with 'paths' is used to revert selected paths in
-the index from a given commit, without moving HEAD.
+The second and third forms with 'paths' and/or --patch are used to
+revert selected paths in the index from a given commit, without moving
+HEAD.
OPTIONS
@@ -50,6 +52,15 @@ OPTIONS
and updates the files that are different between the named commit
and the current commit in the working tree.
+-p::
+--patch::
+ Interactively select hunks in the difference between the index
+ and <commit> (defaults to HEAD). The chosen hunks are applied
+ in reverse to the index.
++
+This means that `git reset -p` is the opposite of `git add -p` (see
+linkgit:git-add[1]).
+
-q::
Be quiet, only report errors.
diff --git a/builtin-reset.c b/builtin-reset.c
index 5fa1789..246a127 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -142,6 +142,17 @@ static void update_index_from_diff(struct diff_queue_struct *q,
}
}
+static int interactive_reset(const char *revision, const char **argv,
+ const char *prefix)
+{
+ const char **pathspec = NULL;
+
+ if (*argv)
+ pathspec = get_pathspec(prefix, argv);
+
+ return run_add_interactive(revision, "--patch=reset", pathspec);
+}
+
static int read_from_tree(const char *prefix, const char **argv,
unsigned char *tree_sha1, int refresh_flags)
{
@@ -183,6 +194,7 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)
int cmd_reset(int argc, const char **argv, const char *prefix)
{
int i = 0, reset_type = NONE, update_ref_status = 0, quiet = 0;
+ int patch_mode = 0;
const char *rev = "HEAD";
unsigned char sha1[20], *orig = NULL, sha1_orig[20],
*old_orig = NULL, sha1_old_orig[20];
@@ -198,6 +210,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
"reset HEAD, index and working tree", MERGE),
OPT_BOOLEAN('q', NULL, &quiet,
"disable showing new HEAD in hard reset and progress message"),
+ OPT_BOOLEAN('p', "patch", &patch_mode, "select hunks interactively"),
OPT_END()
};
@@ -251,6 +264,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
die("Could not parse object '%s'.", rev);
hashcpy(sha1, commit->object.sha1);
+ if (patch_mode) {
+ if (reset_type != NONE)
+ die("--patch is incompatible with --{hard,mixed,soft}");
+ return interactive_reset(rev, argv + i, prefix);
+ }
+
/* git reset tree [--] paths... can be used to
* load chosen paths from the tree into the index without
* affecting the working tree nor HEAD. */
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 3606103..d14f48c 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -72,6 +72,7 @@
# command line options
my $patch_mode;
+my $patch_mode_revision;
sub apply_patch;
@@ -85,6 +86,24 @@
PARTICIPLE => 'staging',
FILTER => 'file-only',
},
+ 'reset_head' => {
+ DIFF => 'diff-index -p --cached',
+ APPLY => sub { apply_patch 'apply -R --cached', @_; },
+ APPLY_CHECK => 'apply -R --cached',
+ VERB => 'Unstage',
+ TARGET => '',
+ PARTICIPLE => 'unstaging',
+ FILTER => 'index-only',
+ },
+ 'reset_nothead' => {
+ DIFF => 'diff-index -R -p --cached',
+ APPLY => sub { apply_patch 'apply --cached', @_; },
+ APPLY_CHECK => 'apply --cached',
+ VERB => 'Apply',
+ TARGET => ' to index',
+ PARTICIPLE => 'applying',
+ FILTER => 'index-only',
+ },
);
my %patch_mode_flavour = %{$patch_modes{stage}};
@@ -206,7 +225,14 @@
return if (!@tracked);
}
- my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
+ my $reference;
+ if (defined $patch_mode_revision and $patch_mode_revision ne 'HEAD') {
+ $reference = $patch_mode_revision;
+ } elsif (is_initial_commit()) {
+ $reference = get_empty_tree();
+ } else {
+ $reference = 'HEAD';
+ }
for (run_cmd_pipe(qw(git diff-index --cached
--numstat --summary), $reference,
'--', @tracked)) {
@@ -640,6 +666,9 @@
sub parse_diff {
my ($path) = @_;
my @diff_cmd = split(" ", $patch_mode_flavour{DIFF});
+ if (defined $patch_mode_revision) {
+ push @diff_cmd, $patch_mode_revision;
+ }
my @diff = run_cmd_pipe("git", @diff_cmd, "--", $path);
my @colored = ();
if ($diff_use_color) {
@@ -1391,11 +1420,31 @@
sub process_args {
return unless @ARGV;
my $arg = shift @ARGV;
- if ($arg eq "--patch") {
- $patch_mode = 1;
- $arg = shift @ARGV or die "missing --";
+ if ($arg =~ /--patch(?:=(.*))?/) {
+ if (defined $1) {
+ if ($1 eq 'reset') {
+ $patch_mode = 'reset_head';
+ $patch_mode_revision = 'HEAD';
+ $arg = shift @ARGV or die "missing --";
+ if ($arg ne '--') {
+ $patch_mode_revision = $arg;
+ $patch_mode = ($arg eq 'HEAD' ?
+ 'reset_head' : 'reset_nothead');
+ $arg = shift @ARGV or die "missing --";
+ }
+ } elsif ($1 eq 'stage') {
+ $patch_mode = 'stage';
+ $arg = shift @ARGV or die "missing --";
+ } else {
+ die "unknown --patch mode: $1";
+ }
+ } else {
+ $patch_mode = 'stage';
+ $arg = shift @ARGV or die "missing --";
+ }
die "invalid argument $arg, expecting --"
unless $arg eq "--";
+ %patch_mode_flavour = %{$patch_modes{$patch_mode}};
}
elsif ($arg ne "--") {
die "invalid argument $arg, expecting --";
diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh
new file mode 100755
index 0000000..c1f4fc3
--- /dev/null
+++ b/t/t7105-reset-patch.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+test_description='git reset --patch'
+. ./lib-patch-mode.sh
+
+test_expect_success 'setup' '
+ mkdir dir &&
+ echo parent > dir/foo &&
+ echo dummy > bar &&
+ git add dir &&
+ git commit -m initial &&
+ test_tick &&
+ test_commit second dir/foo head &&
+ set_and_save_state bar bar_work bar_index &&
+ save_head
+'
+
+# note: bar sorts before foo, so the first 'n' is always to skip 'bar'
+
+test_expect_success 'saying "n" does nothing' '
+ set_and_save_state dir/foo work work
+ (echo n; echo n) | git reset -p &&
+ verify_saved_state dir/foo &&
+ verify_saved_state bar
+'
+
+test_expect_success 'git reset -p' '
+ (echo n; echo y) | git reset -p &&
+ verify_state dir/foo work head &&
+ verify_saved_state bar
+'
+
+test_expect_success 'git reset -p HEAD^' '
+ (echo n; echo y) | git reset -p HEAD^ &&
+ verify_state dir/foo work parent &&
+ verify_saved_state bar
+'
+
+# The idea in the rest is that bar sorts first, so we always say 'y'
+# first and if the path limiter fails it'll apply to bar instead of
+# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
+# the failure case (and thus get out of the loop).
+
+test_expect_success 'git reset -p dir' '
+ set_state dir/foo work work
+ (echo y; echo n) | git reset -p dir &&
+ verify_state dir/foo work head &&
+ verify_saved_state bar
+'
+
+test_expect_success 'git reset -p -- foo (inside dir)' '
+ set_state dir/foo work work
+ (echo y; echo n) | (cd dir && git reset -p -- foo) &&
+ verify_state dir/foo work head &&
+ verify_saved_state bar
+'
+
+test_expect_success 'git reset -p HEAD^ -- dir' '
+ (echo y; echo n) | git reset -p HEAD^ -- dir &&
+ verify_state dir/foo work parent &&
+ verify_saved_state bar
+'
+
+test_expect_success 'none of this moved HEAD' '
+ verify_saved_head
+'
+
+
+test_done
--
1.6.4.287.g3e02d
^ permalink raw reply related
* Re: [PATCH] git-log: allow --decorate[=short|full]
From: Jeff King @ 2009-08-15 12:28 UTC (permalink / raw)
To: Lars Hjemli; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <8c5c35580908150250y62b1042cmf6071016bac98a48@mail.gmail.com>
On Sat, Aug 15, 2009 at 11:50:25AM +0200, Lars Hjemli wrote:
> This extension to --decorate makes it possible to generate decorations
> similar to pre-1.6.4 git, which is nice when the output from git-log
> is used by external tools.
This commit message really lacks context. When I read it, I thought to
myself "what happened to decorations in 1.6.4?" It really needs to say:
- exactly what changed
- why did it change
- why the change has drawbacks
After reading the patch and digging through the history, I think you
want something more like:
-- >8 --
Commit de435ac0 changed the behavior of --decorate from printing the
full ref (e.g., "refs/heads/master") to a shorter, more human-readable
version (e.g., just "master"). While this is nice for human readers,
external tools using the output from "git log" may prefer the full
version.
This patch introduces an extension to --decorate to allow the caller to
specify either the short or the full versions.
-- 8< --
As for the patch, it mostly looks good, but a few comments:
> + } else if (!strncmp(arg, "--decorate=", 11)) {
> + if (!strcmp(arg + 11, "full"))
> + rev->show_decorations = DECORATE_FULL_REFS;
> + else if (!strcmp(arg + 11, "short"))
> + rev->show_decorations = DECORATE_SHORT_REFS;
> + else
> + die("invalid --decorate option: %s", arg + 11);
To avoid the magic 11's, we have a few helpers:
if (!prefixcmp(arg, "--decorate=")) {
const char *v = skip_prefix(arg, "--decorate=");
...
though arguably that is just as bad because you have to repeat the
"--decorate=".
> --- a/revision.h
> +++ b/revision.h
> @@ -15,6 +15,10 @@
> #define SYMMETRIC_LEFT (1u<<8)
> #define ALL_REV_FLAGS ((1u<<9)-1)
>
> +
> +#define DECORATE_SHORT_REFS 1
> +#define DECORATE_FULL_REFS 2
> +
Style nit: extra blank line?
> @@ -56,7 +60,7 @@ struct rev_info {
> rewrite_parents:1,
> print_parents:1,
> show_source:1,
> - show_decorations:1,
> + show_decorations:2,
> reverse:1,
> reverse_output_stage:1,
> cherry_pick:1,
Should we perhaps just turn show_decorations into its own variable? It
just seems like a trap for future maintainers to want to add more
DECORATE_* flags but not realize they have to keep bumping up the size
of the bitfield.
And rev_info is not a struct that we are particularly trying to optimize
the memory on.
> diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
> index 8b33321..8e3694e 100755
> --- a/t/t4013-diff-various.sh
> +++ b/t/t4013-diff-various.sh
> @@ -207,6 +207,7 @@ log --root --cc --patch-with-stat --summary master
> log -SF master
> log -SF -p master
> log --decorate --all
> +log --decorate=full --all
Yay, tests.
-Peff
^ permalink raw reply
* [BUG, PATCH] git add -p: demonstrate failure when staging both mode and hunk
From: Kirill Smelkov @ 2009-08-15 12:26 UTC (permalink / raw)
To: gitster; +Cc: git, Kirill Smelkov, Jeff King, Thomas Rast
When trying to stage changes to file which has also pending `chmod +x`,
`git add -p` produces lots of 'Use of uninitialized value ...' warnings
and fails to do the job:
$ echo content >> file
$ chmod +x file
$ git add -p
diff --git a/file b/file
index e69de29..d95f3ad
--- a/file
+++ b/file
old mode 100644
new mode 100755
Stage mode change [y,n,q,a,d,/,j,J,g,?]? y
@@ -0,0 +1 @@
+content
Stage this hunk [y,n,q,a,d,/,K,g,e,?]? y
Use of uninitialized value $o_ofs in addition (+) at /home/kirr/local/git/libexec/git-core/git-add--interactive line 776.
Use of uninitialized value $ofs in numeric le (<=) at /home/kirr/local/git/libexec/git-core/git-add--interactive line 806.
Use of uninitialized value $o0_ofs in concatenation (.) or string at /home/kirr/local/git/libexec/git-core/git-add--interactive line 830.
Use of uninitialized value $n0_ofs in concatenation (.) or string at /home/kirr/local/git/libexec/git-core/git-add--interactive line 830.
Use of uninitialized value $o_ofs in addition (+) at /home/kirr/local/git/libexec/git-core/git-add--interactive line 776.
fatal: corrupt patch at line 5
diff --git a/file b/file
index e69de29..d95f3ad
--- a/file
+++ b/file
@@ -,0 + @@
+content
Cc: Jeff King <peff@peff.net>
Cc: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
t/t3701-add-interactive.sh | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index fd2a55a..d5e9351 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -163,6 +163,17 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
git diff file | grep "+content"
'
+
+test_expect_failure FILEMODE 'stage mode and hunk' '
+ git reset --hard &&
+ echo content >>file &&
+ chmod +x file &&
+ printf "y\\ny\\n" | git add -p &&
+ git diff --cached file | grep "new mode" &&
+ git diff --cached file | grep "+content" &&
+ test -z "$(git diff file)"
+'
+
# end of tests disabled when filemode is not usable
test_expect_success 'setup again' '
--
1.6.4.134.gb2139
^ permalink raw reply related
* [PATCH] add -p: do not attempt to coalesce mode changes
From: Thomas Rast @ 2009-08-15 13:56 UTC (permalink / raw)
To: gitster, Kirill Smelkov; +Cc: Jeff King, git
In-Reply-To: <1250339209-27962-1-git-send-email-kirr@mns.spb.ru>
In 0392513 (add-interactive: refactor mode hunk handling, 2009-04-16),
we merged the interaction loops for mode changes and hunk staging.
This was fine at the time, because 0beee4c (git-add--interactive:
remove hunk coalescing, 2008-07-02) removed hunk coalescing.
However, in 7a26e65 (Revert "git-add--interactive: remove hunk
coalescing", 2009-05-16), we resurrected it. Since then, the code
would attempt in vain to merge mode changes with diff hunks,
corrupting both in the process.
We add a check to the coalescing loop to ensure it only looks at diff
hunks, thus skipping mode changes.
Noticed-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
git-add--interactive.perl | 4 ++++
t/t3701-add-interactive.sh | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index df9f231..06f7060 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -841,6 +841,10 @@
my ($last_o_ctx, $last_was_dirty);
for (grep { $_->{USE} } @in) {
+ if ($_->{TYPE} ne 'hunk') {
+ push @out, $_;
+ next;
+ }
my $text = $_->{TEXT};
my ($o_ofs) = parse_hunk_header($text->[0]);
if (defined $last_o_ctx &&
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index d5e9351..62fd65e 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -164,7 +164,7 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
'
-test_expect_failure FILEMODE 'stage mode and hunk' '
+test_expect_success FILEMODE 'stage mode and hunk' '
git reset --hard &&
echo content >>file &&
chmod +x file &&
--
1.6.4.288.gc754a.dirty
^ permalink raw reply related
* Re: msysGit and SCons: broken?
From: Dirk Süsserott @ 2009-08-15 14:04 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Dirk Süsserott, Git Mailing List
In-Reply-To: <alpine.DEB.1.00.0908132353380.8306@pacific.mpi-cbg.de>
Am 13.08.2009 23:54 schrieb Johannes Schindelin:
> Hi,
>
> On Thu, 13 Aug 2009, Dirk Süsserott wrote:
>
...
>> If someone had the same or a similar problem: I tracked it down and
>> found a solution. The problem was that I tried to run a Windows program
>> from git-bash. The Windows program then faces the bash's $PATH with a
>> different separator (':' vs. ';') and a different root directory ('/c/'
>> vs. 'C:/').
>
> I cannot believe that. I actually run a Windows program very often, from
> Git Bash, and PATH is correctly converted all the time.
>
> Ciao,
> Dscho
Hmm, I wrote a simple "hello $PATH" and it actually DID print the path
in Windows' flavour when started from Git Bash, like you said. Dunno why
ActivePython ceased to do so as well... Probably I confused my machine
by extending PATH in Windows and .bashrc with different PATHs in
different order. Or ActivePython is somehow "zickig" (what's that in
english? :-)). However, now it works for me and as SCons is the only
tool that failed, I see no further need for investigation.
Btw., I started scons from Git Bash with
cmd //c C:/Python24/Scripts/scons.bat "$@"
Maybe that's a problem, but I don't care any longer.
Dirk
^ permalink raw reply
* Re: [PATCH] add -p: do not attempt to coalesce mode changes
From: Jeff King @ 2009-08-15 14:17 UTC (permalink / raw)
To: Thomas Rast; +Cc: gitster, Kirill Smelkov, git
In-Reply-To: <770693df8f416615f57423141fb59f3d6eccc915.1250344341.git.trast@student.ethz.ch>
On Sat, Aug 15, 2009 at 03:56:39PM +0200, Thomas Rast wrote:
> In 0392513 (add-interactive: refactor mode hunk handling, 2009-04-16),
> we merged the interaction loops for mode changes and hunk staging.
> This was fine at the time, because 0beee4c (git-add--interactive:
> remove hunk coalescing, 2008-07-02) removed hunk coalescing.
>
> However, in 7a26e65 (Revert "git-add--interactive: remove hunk
> coalescing", 2009-05-16), we resurrected it. Since then, the code
> would attempt in vain to merge mode changes with diff hunks,
> corrupting both in the process.
Thanks for the writeup; I bisected the problem to 7a26e65, as well, but
hadn't yet figured out what was going on. :)
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -841,6 +841,10 @@
> my ($last_o_ctx, $last_was_dirty);
>
> for (grep { $_->{USE} } @in) {
> + if ($_->{TYPE} ne 'hunk') {
> + push @out, $_;
> + next;
> + }
> my $text = $_->{TEXT};
> my ($o_ofs) = parse_hunk_header($text->[0]);
> if (defined $last_o_ctx &&
Hmm. I am not too familiar with the coalesce_overlapping_hunks code, but
it looks like we peek at $out[-1] based on $last_o_ctx, assuming that
$last_o_ctx comes from the last hunk pushed (either because we just
pushed it, or we merged into it). So a non-hunk in the middle of some
coalescing hunks is going to violate that assumption.
As it is now, I think we always put the 'mode' hunk at the very
beginning, so that shouldn't happen (and IIRC, that order is preserved
throughout). So maybe it is not worth worrying about. But an alternate
patch is below.
---
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index a06172c..c859bb4 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -838,21 +838,26 @@ sub coalesce_overlapping_hunks {
my (@in) = @_;
my @out = ();
- my ($last_o_ctx, $last_was_dirty);
+ my ($last_o_ctx, $last_was_dirty, $last_hunk);
for (grep { $_->{USE} } @in) {
+ if ($_->{TYPE} ne 'hunk') {
+ push @out, $_;
+ next;
+ }
my $text = $_->{TEXT};
my ($o_ofs) = parse_hunk_header($text->[0]);
if (defined $last_o_ctx &&
$o_ofs <= $last_o_ctx &&
!$_->{DIRTY} &&
!$last_was_dirty) {
- merge_hunk($out[-1], $_);
+ merge_hunk($last_hunk, $_);
}
else {
push @out, $_;
+ $last_hunk = $_;
}
- $last_o_ctx = find_last_o_ctx($out[-1]);
+ $last_o_ctx = find_last_o_ctx($last_hunk);
$last_was_dirty = $_->{DIRTY};
}
return @out;
^ permalink raw reply related
* Re: [PATCH] git-log: allow --decorate[=short|full]
From: Lars Hjemli @ 2009-08-15 14:23 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <20090815122812.GB30630@coredump.intra.peff.net>
Commit de435ac0 changed the behavior of --decorate from printing the
full ref (e.g., "refs/heads/master") to a shorter, more human-readable
version (e.g., just "master"). While this is nice for human readers,
external tools using the output from "git log" may prefer the full
version.
This patch introduces an extension to --decorate to allow the caller to
specify either the short or the full versions.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
Thanks for the review. I've adapted the patch to your comments, and
modified the documentation of '--decorate' to be more specific.
Documentation/git-log.txt | 8 ++++++--
builtin-log.c | 13 +++++++++++--
log-tree.c | 7 ++++---
log-tree.h | 2 +-
pretty.c | 2 +-
revision.c | 2 +-
revision.h | 5 ++++-
t/t4013-diff-various.sh | 1 +
...corate_--all => diff.log_--decorate=full_--all} | 8 ++++----
9 files changed, 33 insertions(+), 15 deletions(-)
copy t/t4013/{diff.log_--decorate_--all =>
diff.log_--decorate=full_--all} (72%)
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 34cf4e5..3d79de1 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -37,8 +37,12 @@ include::diff-options.txt[]
and <until>, see "SPECIFYING REVISIONS" section in
linkgit:git-rev-parse[1].
---decorate::
- Print out the ref names of any commits that are shown.
+--decorate[=short|full]::
+ Print out the ref names of any commits that are shown. If 'short' is
+ specified, the ref name prefixes 'refs/heads/', 'refs/tags/' and
+ 'refs/remotes/' will not be printed. If 'full' is specified, the
+ full ref name (including prefix) will be printed. The default option
+ is 'short'.
--source::
Print out the ref name given on the command line by which each
diff --git a/builtin-log.c b/builtin-log.c
index 3817bf1..1ed4c76 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -61,8 +61,15 @@ static void cmd_log_init(int argc, const char
**argv, const char *prefix,
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--decorate")) {
- load_ref_decorations();
- rev->show_decorations = 1;
+ rev->show_decorations = DECORATE_SHORT_REFS;
+ } else if (!prefixcmp(arg, "--decorate=")) {
+ const char *v = skip_prefix(arg, "--decorate=");
+ if (!strcmp(v, "full"))
+ rev->show_decorations = DECORATE_FULL_REFS;
+ else if (!strcmp(v, "short"))
+ rev->show_decorations = DECORATE_SHORT_REFS;
+ else
+ die("invalid --decorate option: %s", arg);
} else if (!strcmp(arg, "--source")) {
rev->show_source = 1;
} else if (!strcmp(arg, "-h")) {
@@ -70,6 +77,8 @@ static void cmd_log_init(int argc, const char
**argv, const char *prefix,
} else
die("unrecognized argument: %s", arg);
}
+ if (rev->show_decorations)
+ load_ref_decorations(rev->show_decorations);
}
/*
diff --git a/log-tree.c b/log-tree.c
index 6f73c17..70223eb 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -25,7 +25,8 @@ static int add_ref_decoration(const char *refname,
const unsigned char *sha1, in
struct object *obj = parse_object(sha1);
if (!obj)
return 0;
- refname = prettify_refname(refname);
+ if (!cb_data || *(int *)cb_data & DECORATE_SHORT_REFS)
+ refname = prettify_refname(refname);
add_name_decoration("", refname, obj);
while (obj->type == OBJ_TAG) {
obj = ((struct tag *)obj)->tagged;
@@ -36,12 +37,12 @@ static int add_ref_decoration(const char *refname,
const unsigned char *sha1, in
return 0;
}
-void load_ref_decorations(void)
+void load_ref_decorations(int flags)
{
static int loaded;
if (!loaded) {
loaded = 1;
- for_each_ref(add_ref_decoration, NULL);
+ for_each_ref(add_ref_decoration, &flags);
}
}
diff --git a/log-tree.h b/log-tree.h
index 20b5caf..3f7b400 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -17,7 +17,7 @@ void log_write_email_headers(struct rev_info *opt,
struct commit *commit,
const char **subject_p,
const char **extra_headers_p,
int *need_8bit_cte_p);
-void load_ref_decorations(void);
+void load_ref_decorations(int flags);
#define FORMAT_PATCH_NAME_MAX 64
void get_patch_filename(struct commit *commit, int nr, const char *suffix,
diff --git a/pretty.c b/pretty.c
index e5328da..daa721b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -571,7 +571,7 @@ static void format_decoration(struct strbuf *sb,
const struct commit *commit)
struct name_decoration *d;
const char *prefix = " (";
- load_ref_decorations();
+ load_ref_decorations(DECORATE_SHORT_REFS);
d = lookup_decoration(&name_decoration, &commit->object);
while (d) {
strbuf_addstr(sb, prefix);
diff --git a/revision.c b/revision.c
index 9f5dac5..ce24ad9 100644
--- a/revision.c
+++ b/revision.c
@@ -1052,7 +1052,7 @@ static int handle_revision_opt(struct rev_info
*revs, int argc, const char **arg
revs->simplify_by_decoration = 1;
revs->limited = 1;
revs->prune = 1;
- load_ref_decorations();
+ load_ref_decorations(DECORATE_SHORT_REFS);
} else if (!strcmp(arg, "--date-order")) {
revs->lifo = 0;
revs->topo_order = 1;
diff --git a/revision.h b/revision.h
index fb74492..9a644ee 100644
--- a/revision.h
+++ b/revision.h
@@ -15,6 +15,9 @@
#define SYMMETRIC_LEFT (1u<<8)
#define ALL_REV_FLAGS ((1u<<9)-1)
+#define DECORATE_SHORT_REFS 1
+#define DECORATE_FULL_REFS 2
+
struct rev_info;
struct log_info;
@@ -56,7 +59,6 @@ struct rev_info {
rewrite_parents:1,
print_parents:1,
show_source:1,
- show_decorations:1,
reverse:1,
reverse_output_stage:1,
cherry_pick:1,
@@ -96,6 +98,7 @@ struct rev_info {
const char *subject_prefix;
int no_inline;
int show_log_size;
+ int show_decorations;
/* Filter by commit log message */
struct grep_opt grep_filter;
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 8b33321..8e3694e 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -207,6 +207,7 @@ log --root --cc --patch-with-stat --summary master
log -SF master
log -SF -p master
log --decorate --all
+log --decorate=full --all
rev-list --parents HEAD
rev-list --children HEAD
diff --git a/t/t4013/diff.log_--decorate_--all
b/t/t4013/diff.log_--decorate=full_--all
similarity index 72%
copy from t/t4013/diff.log_--decorate_--all
copy to t/t4013/diff.log_--decorate=full_--all
index 954210e..903d9d9 100644
--- a/t/t4013/diff.log_--decorate_--all
+++ b/t/t4013/diff.log_--decorate=full_--all
@@ -1,12 +1,12 @@
-$ git log --decorate --all
-commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (master)
+$ git log --decorate=full --all
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (refs/heads/master)
Merge: 9a6d494 c7a2ab9
Author: A U Thor <author@example.com>
Date: Mon Jun 26 00:04:00 2006 +0000
Merge branch 'side'
-commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side)
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side)
Author: A U Thor <author@example.com>
Date: Mon Jun 26 00:03:00 2006 +0000
@@ -26,7 +26,7 @@ Date: Mon Jun 26 00:01:00 2006 +0000
This is the second commit.
-commit 444ac553ac7612cc88969031b02b3767fb8a353a (initial)
+commit 444ac553ac7612cc88969031b02b3767fb8a353a (refs/heads/initial)
Author: A U Thor <author@example.com>
Date: Mon Jun 26 00:00:00 2006 +0000
--
1.6.4.135.g4e5b
^ permalink raw reply related
* Integration of git release workflow with automake "make dist"
From: Roger Leigh @ 2009-08-15 14:21 UTC (permalink / raw)
To: git
[-- Attachment #1.1: Type: text/plain, Size: 1951 bytes --]
[I'm not subscribed to the list, so I'd appreciate a CC on reply, thanks!]
Hi folks,
After initially bringing up the idea behind this initial implementation
on the automake mailing list, I want to get some criticism and comments
from automake users who use git (or git experts in general in case my
use of the git plumbing is not correct!).
The initial discussion is here:
http://thread.gmane.org/gmane.comp.sysutils.automake.general/10936
And the current implementation is attached.
Automake has a "dist" target to generate a "release" in the form of a
compressed tarfile or zip file. This file contains files not normally
kept under version control in the developer's repo (generated autotools
scripts, other generated files such as changelogs etc.) as well as
possibly excluding other bits in the repo not needed by end users.
However, this isn't kept under version control, and it would be
helpful it it was.
The above thread contains most of the rationale behind doing this, so
I won't repeat it all here.
The attached make fragment implements a "dist-git" target. Instead
of releasing by creating a tarball, it injects the same tree onto a
specified git branch and (optionally) signs both the release and
distribution branches. Branch and tag names and messages are
configurable. Note this is just an initial proof of concept;
anything can be changed!
I'd like to make this as generally usable for as many people as
possible, so it would be great to hear how you are managing releases
with automake and git, and if this would be useful for you, and if
there's anything that could be added or changed to better accommodate
you.
Many thanks,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
[-- Attachment #1.2: automake-dist-git.mk --]
[-- Type: text/plain, Size: 2872 bytes --]
ENABLE_DIST_GIT=false
GIT_RELEASE_BRANCH=HEAD
GIT_RELEASE_TAG=true
GIT_RELEASE_TAG_SIGN=true
GIT_RELEASE_TAG_NAME=release/$(PACKAGE)-$(VERSION)
GIT_RELEASE_TAG_MESSAGE="Release of $(PACKAGE)-$(VERSION)"
GIT_DIST_BRANCH=distribution
GIT_DIST_COMMIT_MESSAGE="Distribution of $(PACKAGE) version $(VERSION)"
GIT_DIST_TAG=true
GIT_DIST_TAG_SIGN=true
GIT_DIST_TAG_NAME=distribution/$(PACKAGE)-$(VERSION)
GIT_DIST_TAG_MESSAGE="Distribution of $(PACKAGE)-$(VERSION)"
dist-git: distdir
if [ "$(ENABLE_DIST_GIT)" != "true" ]; then \
echo "$@: ENABLE_DIST_GIT not true; not distributing"; \
exit 0; \
fi; \
cd "$(abs_top_srcdir)"; \
if [ ! -d .git ]; then \
echo "$@: Not a git repository" 1>&2; \
exit 1; \
fi; \
if [ "$(GIT_RELEASE_TAG)" = "true" ]; then \
if git show-ref --tags -q $(GIT_RELEASE_TAG_NAME); then \
echo "git release tag $(GIT_RELEASE_TAG_NAME) already exists; not distributing" 1>&2; \
exit 1; \
fi; \
fi; \
if [ "$(GIT_DIST_TAG)" = "true" ]; then \
if git show-ref --tags -q $(GIT_DIST_TAG_NAME); then \
echo "git distribution tag $(GIT_DIST_TAG_NAME) already exists; not distributing" 1>&2; \
exit 1; \
fi; \
fi; \
echo "$@: distributing $(PACKAGE)-$(VERSION) on git branch $(GIT_DIST_BRANCH)"; \
DISTDIR_INDEX="$(abs_top_builddir)/$(distdir).git.idx"; \
DISTDIR_TREE="$(abs_top_builddir)/$(distdir)"; \
rm -f "$$DISTDIR_INDEX"; \
GIT_INDEX_FILE="$$DISTDIR_INDEX" GIT_WORK_TREE="$$DISTDIR_TREE" git add -A || exit 1; \
GIT_INDEX_FILE="$$DISTDIR_INDEX" TREE="$$(git write-tree)"; \
rm -f "$$DISTDIR_INDEX"; \
[ -n "$$TREE" ] || exit 1; \
RELEASE_HEAD="$$(git show-ref -s $(GIT_RELEASE_BRANCH))"; \
COMMIT_OPTS="-p $$RELEASE_HEAD"; \
DIST_PARENT="$$(git show-ref --heads -s refs/heads/$(GIT_DIST_BRANCH))"; \
if [ -n "$$DIST_PARENT" ]; then \
COMMIT_OPTS="$$COMMIT_OPTS -p $$DIST_PARENT"; \
fi; \
COMMIT="$$(echo $(GIT_DIST_COMMIT_MESSAGE) | git commit-tree "$$TREE" $$COMMIT_OPTS)"; \
[ -n "$$COMMIT" ] || exit 1; \
git update-ref "refs/heads/$(GIT_DIST_BRANCH)" "$$COMMIT" "$$DIST_PARENT" || exit 1;\
echo "$@: tree=$$TREE"; \
echo "$@: commit=$$COMMIT"; \
if [ "$(GIT_RELEASE_TAG)" = "true" ]; then \
RELEASE_TAG_OPTS=""; \
if [ "$(GIT_RELEASE_TAG_SIGN)" = "true" ]; then \
RELEASE_TAG_OPTS="$$TAG_OPTS -s"; \
fi; \
git tag -m $(GIT_RELEASE_TAG_MESSAGE) $$RELEASE_TAG_OPTS "$(GIT_RELEASE_TAG_NAME)" "$$COMMIT" || exit 1; \
echo "$@: release tagged as $(GIT_RELEASE_TAG_NAME)"; \
fi; \
if [ "$(GIT_DIST_TAG)" = "true" ]; then \
DIST_TAG_OPTS=""; \
if [ "$(GIT_DIST_TAG_SIGN)" = "true" ]; then \
DIST_TAG_OPTS="$$TAG_OPTS -s"; \
fi; \
git tag -m $(GIT_DIST_TAG_MESSAGE) $$DIST_TAG_OPTS "$(GIT_DIST_TAG_NAME)" "$$COMMIT" || exit 1; \
echo "$@: distribution tagged as $(GIT_DIST_TAG_NAME)"; \
fi;
$(am__remove_distdir)
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [PATCH] add -p: do not attempt to coalesce mode changes
From: Thomas Rast @ 2009-08-15 14:35 UTC (permalink / raw)
To: Jeff King; +Cc: gitster, Kirill Smelkov, git
In-Reply-To: <20090815141710.GA15978@sigill.intra.peff.net>
Jeff King wrote:
>
> > --- a/git-add--interactive.perl
> > +++ b/git-add--interactive.perl
> > @@ -841,6 +841,10 @@
> > my ($last_o_ctx, $last_was_dirty);
> >
> > for (grep { $_->{USE} } @in) {
> > + if ($_->{TYPE} ne 'hunk') {
> > + push @out, $_;
> > + next;
> > + }
> > my $text = $_->{TEXT};
> > my ($o_ofs) = parse_hunk_header($text->[0]);
> > if (defined $last_o_ctx &&
>
> Hmm. I am not too familiar with the coalesce_overlapping_hunks code, but
> it looks like we peek at $out[-1] based on $last_o_ctx, assuming that
> $last_o_ctx comes from the last hunk pushed (either because we just
> pushed it, or we merged into it). So a non-hunk in the middle of some
> coalescing hunks is going to violate that assumption.
>
> As it is now, I think we always put the 'mode' hunk at the very
> beginning, so that shouldn't happen (and IIRC, that order is preserved
> throughout). So maybe it is not worth worrying about. But an alternate
> patch is below.
Hmm. I briefly considered worrying about futureproofing, but then
decided it wasn't worth it since we also rely on
coalesce_overlapping_hunks only being run over the hunks of a single
file. But since you already went to the lengths of doing it, feel
free to take the explanation in my commit message and add my Acked-by
:-)
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [PATCH] git-instaweb: fix mod_perl detection for apache2
From: Mark A Rada @ 2009-08-15 16:09 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Junio C Hamano, Mark A Rada, git
In-Reply-To: <m3iqgwoxq7.fsf@localhost.localdomain>
Does this means it may be taken off the menu in the not too distant
future or
deprecated?
--
Mark A Rada (ferrous26)
marada@uwaterloo.ca
On 10-Aug-09, at 4:55 AM, Jakub Narebski wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Mark A Rada <marada@uwaterloo.ca> writes:
>>
>>> The script was looking for something that matched the '^our $gitbin'
>>> regex, which no longer exists in gitweb.cgi.
>>>
>>> Now it looks for 'MOD_PERL', which should be on the line that checks
>>> to see if the script is running in a mod_perl environment.
>>
>> Thanks. That sounds like an ancient bug that in turn perhaps
>> suggests
>> nobody uses instaweb. Will apply to 'maint'..
>
> Hmmm... taking a peek at current "Git User's Survey 2009" results
> http://www.survs.com/shareResults?survey=2PIMZGU0&rndm=678J66QRA2
>
> 11. What Git interfaces, implementations, frontends and tools do you
> use?
>
> git-instaweb 3% 77 / 2712
>
> 16. How often do you use the following forms of git commands or extra
> git tools?
>
> git instaweb
> never: 1983 - 79%
> rarely: 208 - 8%
> sometimes: 50 - 2%
> often: 9 - 0%
>
> Total respondents 2506
>
> --
> Jakub Narebski
> Poland
> ShadeHawk on #git
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Using VC build git (new patch)
From: Frank Li @ 2009-08-15 16:21 UTC (permalink / raw)
To: git, msysGit
[-- Attachment #1: Type: text/plain, Size: 63 bytes --]
New patch.
pull from git://repo.or.cz/tgit.git
branch vcpatch
[-- Attachment #2: 0001-Enable-Visual-Studio-2008-Build-Git.patch --]
[-- Type: application/octet-stream, Size: 52895 bytes --]
From 3136d3b72e199ad1484629e8ff4563a918cad953 Mon Sep 17 00:00:00 2001
From: Frank Li <lznuaa@gmail.com>
Date: Tue, 4 Aug 2009 23:53:38 +0800
Subject: [PATCH] Enable Visual Studio 2008 Build Git
Enable VC Build Git. Reuse many msysgit porting working.
Build Git need some external library, such zlib.
Please read Readme to get how to build git with VS2008
Signed-off-by: Frank Li <lznuaa@gmail.com>
---
builtin-fast-export.c | 1 +
compat/fnmatch/fnmatch.c | 2 +
compat/mingw.c | 68 ++-
compat/mingw.h | 21 +-
compat/regex/regex.c | 8 +-
compat/snprintf.c | 7 +-
compat/vcbuild/.gitignore | 3 +
compat/vcbuild/ReadMe | 13 +
compat/vcbuild/git/git.vcproj | 197 +++++
compat/vcbuild/include/dirent.h | 127 ++++
compat/vcbuild/include/unistd.h | 174 +++++
compat/vcbuild/libgit/libgit.vcproj | 1347 +++++++++++++++++++++++++++++++++++
compat/vcbuild/porting.c | 13 +
compat/vcbuild/sys/time.h | 21 +
compat/winansi.c | 8 +
git-compat-util.h | 2 +-
help.c | 5 +-
| 4 +-
run-command.c | 11 +-
run-command.h | 2 +-
setup.c | 2 +-
21 files changed, 2011 insertions(+), 25 deletions(-)
create mode 100644 compat/vcbuild/.gitignore
create mode 100644 compat/vcbuild/ReadMe
create mode 100644 compat/vcbuild/git/git.vcproj
create mode 100644 compat/vcbuild/include/dirent.h
create mode 100644 compat/vcbuild/include/unistd.h
create mode 100644 compat/vcbuild/include/utime.h
create mode 100644 compat/vcbuild/libgit/libgit.vcproj
create mode 100644 compat/vcbuild/porting.c
create mode 100644 compat/vcbuild/sys/param.h
create mode 100644 compat/vcbuild/sys/socket.h
create mode 100644 compat/vcbuild/sys/time.h
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index c48c18d..24a50ae 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -24,6 +24,7 @@ static const char *fast_export_usage[] = {
static int progress;
static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
+#undef ERROR
static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
static int fake_missing_tagger;
diff --git a/compat/fnmatch/fnmatch.c b/compat/fnmatch/fnmatch.c
index 14feac7..4e3d8e7 100644
--- a/compat/fnmatch/fnmatch.c
+++ b/compat/fnmatch/fnmatch.c
@@ -16,6 +16,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include "git-compat-util.h"
+
#if HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/compat/mingw.c b/compat/mingw.c
index bed4178..4ff2e84 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -123,13 +123,19 @@ int mingw_open (const char *filename, int oflags, ...)
{
va_list args;
unsigned mode;
+ int fd;
+
va_start(args, oflags);
mode = va_arg(args, int);
va_end(args);
if (!strcmp(filename, "/dev/null"))
filename = "nul";
- int fd = open(filename, oflags, mode);
+#if defined(_MSC_VER)
+ fd = _open(filename, oflags|_O_BINARY, mode);
+#else
+ fd = open(filename, oflags, mode);
+#endif
if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
DWORD attrs = GetFileAttributes(filename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
@@ -274,7 +280,11 @@ int mkstemp(char *template)
char *filename = mktemp(template);
if (filename == NULL)
return -1;
+#if defined(_MSC_VER)
+ return _open(filename, _O_RDWR | _O_CREAT | _O_BINARY, 0600);
+#else
return open(filename, O_RDWR | O_CREAT, 0600);
+#endif
}
int gettimeofday(struct timeval *tv, void *tz)
@@ -580,10 +590,11 @@ static char **get_path_split(void)
static void free_path_split(char **path)
{
+ char **p = path;
+
if (!path)
return;
-
- char **p = path;
+
while (*p)
free(*p++);
free(path);
@@ -938,7 +949,6 @@ int mingw_rename(const char *pold, const char *pnew)
DWORD attrs, gle;
int tries = 0;
static const int delay[] = { 0, 1, 10, 20, 40 };
-
/*
* Try native rename() first to get errno right.
* It is based on MoveFile(), which cannot overwrite existing files.
@@ -1011,7 +1021,9 @@ static sig_handler_t timer_fn = SIG_DFL;
* But ticktack() interrupts the wait state after the timer's interval
* length to call the signal handler.
*/
-
+#if defined(_MSC_VER)
+#define __stdcall
+#endif
static __stdcall unsigned ticktack(void *dummy)
{
while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) {
@@ -1108,9 +1120,11 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
#undef signal
sig_handler_t mingw_signal(int sig, sig_handler_t handler)
{
+ sig_handler_t old;
+
if (sig != SIGALRM)
return signal(sig, handler);
- sig_handler_t old = timer_fn;
+ old = timer_fn;
timer_fn = handler;
return old;
}
@@ -1141,6 +1155,12 @@ int link(const char *oldpath, const char *newpath)
{
typedef BOOL WINAPI (*T)(const char*, const char*, LPSECURITY_ATTRIBUTES);
static T create_hard_link = NULL;
+
+#if defined(_MSC_VER)
+ errno = ENOSYS;
+ return -1;
+#endif
+
if (!create_hard_link) {
create_hard_link = (T) GetProcAddress(
GetModuleHandle("kernel32.dll"), "CreateHardLinkA");
@@ -1197,8 +1217,9 @@ struct dirent *mingw_readdir(DIR *dir)
if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0)
{
+ DWORD lasterr;
handle = FindFirstFileA(dir->dd_name, &buf);
- DWORD lasterr = GetLastError();
+ lasterr = GetLastError();
dir->dd_handle = (long)handle;
if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) {
errno = err_win_to_posix(lasterr);
@@ -1230,4 +1251,37 @@ struct dirent *mingw_readdir(DIR *dir)
return (struct dirent*)&dir->dd_dir;
}
+#if defined(_MSC_VER)
+DIR *opendir(const char *name)
+{
+ int len;
+ DIR *p;
+ p=(DIR*)malloc(sizeof(DIR));
+ memset(p,0,sizeof(DIR));
+ strncpy(p->dd_name,name,PATH_MAX);
+ len=strlen(p->dd_name);
+ p->dd_name[len]='/';
+ p->dd_name[len+1]='*';
+
+ if(p==NULL)
+ return NULL;
+
+ p->dd_handle=_findfirst(p->dd_name,&p->dd_dta);
+
+ if(p->dd_handle == -1)
+ {
+ free(p);
+ return NULL;
+ }
+ return p;
+}
+int closedir(DIR *dir)
+{
+ _findclose(dir->dd_handle);
+ free(dir);
+ return 0;
+}
+#endif //_MSC_VER
+
#endif // !NO_MINGW_REPLACE_READDIR
+
diff --git a/compat/mingw.h b/compat/mingw.h
index c1859c5..0eb2bc7 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -171,14 +171,31 @@ int mingw_getpagesize(void);
/* Use mingw_lstat() instead of lstat()/stat() and
* mingw_fstat() instead of fstat() on Windows.
*/
+#undef off_t
#define off_t off64_t
+
+#ifdef _MSC_VER
+#define stat(x,y) mingw_lstat(x,y)
+#define stat _stat64
+#else
#define stat _stati64
+#endif
+
+#undef lseek
#define lseek _lseeki64
+
int mingw_lstat(const char *file_name, struct stat *buf);
int mingw_fstat(int fd, struct stat *buf);
+
+#undef fstat
#define fstat mingw_fstat
+
+#undef lstat
#define lstat mingw_lstat
+
+#ifndef _MSC_VER
#define _stati64(x,y) mingw_lstat(x,y)
+#endif
int mingw_utime(const char *file_name, const struct utimbuf *times);
#define utime mingw_utime
@@ -197,7 +214,9 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler);
/*
* ANSI emulation wrappers
*/
-
+#ifdef _MSC_VER
+#define __attribute__(x)
+#endif
int winansi_fputs(const char *str, FILE *stream);
int winansi_printf(const char *format, ...) __attribute__((format (printf, 1, 2)));
int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3)));
diff --git a/compat/regex/regex.c b/compat/regex/regex.c
index 5ea0075..a291543 100644
--- a/compat/regex/regex.c
+++ b/compat/regex/regex.c
@@ -20,6 +20,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* AIX requires this to be the first thing in the file. */
+#include "git-compat-util.h"
+
#if defined (_AIX) && !defined (REGEX_MALLOC)
#pragma alloca
#endif
@@ -4852,11 +4854,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
from either regcomp or regexec. We don't use PREG here. */
size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
+regerror (int errcode, const regex_t * preg, char * errbuf,size_t errbuf_size)
{
const char *msg;
size_t msg_size;
diff --git a/compat/snprintf.c b/compat/snprintf.c
index 6c0fb05..47b2b8a 100644
--- a/compat/snprintf.c
+++ b/compat/snprintf.c
@@ -6,7 +6,7 @@
* number of characters to write without the trailing NUL.
*/
#ifndef SNPRINTF_SIZE_CORR
-#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4
+#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4 || defined(_MSC_VER)
#define SNPRINTF_SIZE_CORR 1
#else
#define SNPRINTF_SIZE_CORR 0
@@ -14,6 +14,11 @@
#endif
#undef vsnprintf
+
+#if defined(_MSC_VER)
+#define vsnprintf _vsnprintf
+#endif
+
int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
{
char *s;
diff --git a/compat/vcbuild/.gitignore b/compat/vcbuild/.gitignore
new file mode 100644
index 0000000..7796990
--- /dev/null
+++ b/compat/vcbuild/.gitignore
@@ -0,0 +1,3 @@
+Debug
+Release
+*.user
\ No newline at end of file
diff --git a/compat/vcbuild/ReadMe b/compat/vcbuild/ReadMe
new file mode 100644
index 0000000..47c089e
--- /dev/null
+++ b/compat/vcbuild/ReadMe
@@ -0,0 +1,13 @@
+The Steps of Build Git with VS2008
+
+1. Create VC Build Environment.
+
+ git clone git://repo.or.cz/gitbuild.git
+
+ gitbuild include VS solution file and library such as zlib.
+
+2. Get Submodule
+
+ git submodule update
+
+3. Open gitbuild\gitbuild.sln with VS2008. Then press F7.
\ No newline at end of file
diff --git a/compat/vcbuild/git/git.vcproj b/compat/vcbuild/git/git.vcproj
new file mode 100644
index 0000000..6f85de3
--- /dev/null
+++ b/compat/vcbuild/git/git.vcproj
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="git"
+ ProjectGUID="{E3E30E51-C5AD-407B-AB43-985E4111474A}"
+ RootNamespace="git"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..;..\..\..\..\zlib;..\..;..\;..\include;..\..\..\compat;..\..\..\compat\fnmatch;..\..\..\compat\regex;.\"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="wininet.lib ws2_32.lib "
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\..;..\..\..\..\zlib;..\..;..\;..\include;..\..\..\compat;..\..\..\compat\fnmatch;..\..\..\compat\regex;.\"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="wininet.lib ws2_32.lib "
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\..\git.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/compat/vcbuild/include/dirent.h b/compat/vcbuild/include/dirent.h
new file mode 100644
index 0000000..a6b6f4c
--- /dev/null
+++ b/compat/vcbuild/include/dirent.h
@@ -0,0 +1,127 @@
+/*
+ * DIRENT.H (formerly DIRLIB.H)
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ */
+#ifndef _DIRENT_H_
+#define _DIRENT_H_
+
+/* All the headers include this file. */
+//#include <_mingw.h>
+
+#include <io.h>
+
+#define PATH_MAX 512
+
+#define __MINGW_NOTHROW
+
+#ifndef RC_INVOKED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct dirent
+{
+ long d_ino; /* Always zero. */
+ unsigned short d_reclen; /* Always zero. */
+ unsigned short d_namlen; /* Length of name in d_name. */
+ char d_name[FILENAME_MAX]; /* File name. */
+};
+
+/*
+ * This is an internal data structure. Good programmers will not use it
+ * except as an argument to one of the functions below.
+ * dd_stat field is now int (was short in older versions).
+ */
+typedef struct
+{
+ /* disk transfer area for this dir */
+ struct _finddata_t dd_dta;
+
+ /* dirent struct to return from dir (NOTE: this makes this thread
+ * safe as long as only one thread uses a particular DIR struct at
+ * a time) */
+ struct dirent dd_dir;
+
+ /* _findnext handle */
+ long dd_handle;
+
+ /*
+ * Status of search:
+ * 0 = not started yet (next entry to read is first entry)
+ * -1 = off the end
+ * positive = 0 based index of next entry
+ */
+ int dd_stat;
+
+ /* given path for dir with search pattern (struct is extended) */
+ char dd_name[PATH_MAX+3];
+} DIR;
+
+DIR* __cdecl __MINGW_NOTHROW opendir (const char*);
+struct dirent* __cdecl __MINGW_NOTHROW readdir (DIR*);
+int __cdecl __MINGW_NOTHROW closedir (DIR*);
+void __cdecl __MINGW_NOTHROW rewinddir (DIR*);
+long __cdecl __MINGW_NOTHROW telldir (DIR*);
+void __cdecl __MINGW_NOTHROW seekdir (DIR*, long);
+
+
+/* wide char versions */
+
+struct _wdirent
+{
+ long d_ino; /* Always zero. */
+ unsigned short d_reclen; /* Always zero. */
+ unsigned short d_namlen; /* Length of name in d_name. */
+ wchar_t d_name[FILENAME_MAX]; /* File name. */
+};
+
+/*
+ * This is an internal data structure. Good programmers will not use it
+ * except as an argument to one of the functions below.
+ */
+typedef struct
+{
+ /* disk transfer area for this dir */
+ //struct _wfinddata_t dd_dta;
+
+ /* dirent struct to return from dir (NOTE: this makes this thread
+ * safe as long as only one thread uses a particular DIR struct at
+ * a time) */
+ struct _wdirent dd_dir;
+
+ /* _findnext handle */
+ long dd_handle;
+
+ /*
+ * Status of search:
+ * 0 = not started yet (next entry to read is first entry)
+ * -1 = off the end
+ * positive = 0 based index of next entry
+ */
+ int dd_stat;
+
+ /* given path for dir with search pattern (struct is extended) */
+ wchar_t dd_name[1];
+} _WDIR;
+
+
+
+_WDIR* __cdecl __MINGW_NOTHROW _wopendir (const wchar_t*);
+struct _wdirent* __cdecl __MINGW_NOTHROW _wreaddir (_WDIR*);
+int __cdecl __MINGW_NOTHROW _wclosedir (_WDIR*);
+void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR*);
+long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR*);
+void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR*, long);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* Not RC_INVOKED */
+
+#endif /* Not _DIRENT_H_ */
diff --git a/compat/vcbuild/include/unistd.h b/compat/vcbuild/include/unistd.h
new file mode 100644
index 0000000..0c06957
--- /dev/null
+++ b/compat/vcbuild/include/unistd.h
@@ -0,0 +1,174 @@
+#ifndef _UNISTD_
+#define _UNISTD_
+
+/*Configuration*/
+
+#define NO_PREAD
+#define NO_OPENSSL
+#define NO_LIBGEN_H
+#define NO_SYMLINK_HEAD
+#define NO_IPV6
+#define NO_SETENV
+#define NO_UNSETENV
+#define NO_STRCASESTR
+#define NO_STRLCPY
+#define NO_MEMMEM
+#define NO_C99_FORMAT
+#define NO_STRTOUMAX
+#define NO_MKDTEMP
+#define NO_MKSTEMPS
+
+#define RUNTIME_PREFIX
+#define NO_ST_BLOCKS_IN_STRUCT_STAT
+#define NO_NSEC
+#define USE_WIN32_MMAP
+#define USE_NED_ALLOCATOR
+
+#define NO_REGEX
+
+#define NO_SYS_SELECT_H
+#define NO_PTHEADS
+#define HAVE_STRING_H 1
+#define STDC_HEADERS
+#define NO_ICONV
+
+#define WINVER 0x0500
+#define _WIN32_WINNT 0x0500
+#define _WIN32_WINDOWS 0x0410
+#define _WIN32_IE 0x0700
+#define NTDDI_VERSION NTDDI_WIN2KSP1
+#define inline __inline
+#define __inline__ __inline
+
+#define SNPRINTF_RETURNS_BOGUS
+
+#define SHA1_HEADER "mozilla-sha1\\sha1.h"
+
+#define ETC_GITCONFIG "%HOME%"
+
+#define NO_PTHREADS
+#define NO_CURL
+
+
+#define va_copy va_start
+#define NO_STRTOUMAX
+#define REGEX_MALLOC
+
+
+
+
+/* Win32 define for porting git*/
+
+#ifndef _MODE_T_
+#define _MODE_T_
+typedef unsigned short _mode_t;
+
+#ifndef _NO_OLDNAMES
+typedef _mode_t mode_t;
+#endif
+#endif /* Not _MODE_T_ */
+
+#ifndef _SSIZE_T_
+#define _SSIZE_T_
+typedef long _ssize_t;
+
+#ifndef _OFF_T_
+#define _OFF_T_
+typedef long _off_t;
+
+#ifndef _NO_OLDNAMES
+typedef _off_t off_t;
+#endif
+#endif /* Not _OFF_T_ */
+
+
+#ifndef _NO_OLDNAMES
+typedef _ssize_t ssize_t;
+#endif
+#endif /* Not _SSIZE_T_ */
+
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef short int16_t;
+typedef unsigned short uint16_t;
+typedef int int32_t;
+typedef unsigned uint32_t;
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
+
+typedef int64_t off64_t;
+
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+/* Some defines for _access nAccessMode (MS doesn't define them, but
+ * it doesn't seem to hurt to add them). */
+#define F_OK 0 /* Check for file existence */
+/* Well maybe it does hurt. On newer versions of MSVCRT, an access mode
+ of 1 causes invalid parameter error. */
+#define X_OK 0 /* MS access() doesn't check for execute permission. */
+#define W_OK 2 /* Check for write permission */
+#define R_OK 4 /* Check for read permission */
+
+#define _S_IFIFO 0x1000 /* FIFO */
+#define _S_IFCHR 0x2000 /* Character */
+#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
+#define _S_IFDIR 0x4000 /* Directory */
+#define _S_IFREG 0x8000 /* Regular */
+
+#define _S_IFMT 0xF000 /* File type mask */
+
+#define _S_IXUSR _S_IEXEC
+#define _S_IWUSR _S_IWRITE
+#define _S_IRUSR _S_IREAD
+#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+
+#define S_IFIFO _S_IFIFO
+#define S_IFCHR _S_IFCHR
+#define S_IFBLK _S_IFBLK
+#define S_IFDIR _S_IFDIR
+#define S_IFREG _S_IFREG
+#define S_IFMT _S_IFMT
+#define S_IEXEC _S_IEXEC
+#define S_IWRITE _S_IWRITE
+#define S_IREAD _S_IREAD
+#define S_IRWXU _S_IRWXU
+#define S_IXUSR _S_IXUSR
+#define S_IWUSR _S_IWUSR
+#define S_IRUSR _S_IRUSR
+
+
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+
+//#define S_IWGRP _S_IWGRP
+
+
+#define GIT_EXEC_PATH "bin"
+#define GIT_VERSION "1.6"
+#define BINDIR "bin"
+#define PREFIX "."
+#define GIT_MAN_PATH "man"
+#define GIT_INFO_PATH "info"
+#define GIT_HTML_PATH "html"
+#define DEFAULT_GIT_TEMPLATE_DIR "templates"
+
+#define NO_STRLCPY
+#define NO_UNSETENV
+#define NO_SETENV
+
+#define strdup _strdup
+#define read _read
+#define close _close
+#define dup _dup
+#define dup2 _dup2
+#define strncasecmp _strnicmp
+#define strtoull _strtoui64
+
+//#define lseek _lseek
+//#define write vs_write
+#endif
\ No newline at end of file
diff --git a/compat/vcbuild/include/utime.h b/compat/vcbuild/include/utime.h
new file mode 100644
index 0000000..e69de29
diff --git a/compat/vcbuild/libgit/libgit.vcproj b/compat/vcbuild/libgit/libgit.vcproj
new file mode 100644
index 0000000..06dcdef
--- /dev/null
+++ b/compat/vcbuild/libgit/libgit.vcproj
@@ -0,0 +1,1347 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libgit"
+ ProjectGUID="{F6DEC8C3-B803-4A86-8848-430F08B499E3}"
+ RootNamespace="libgit"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="..\..\..;..\..\..\..\zlib;..\..;..\;..\include;..\..\..\compat;..\..\..\compat\fnmatch;..\..\..\compat\regex;.\"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\..;..\..\..\..\zlib;..\..;..\;..\include;..\..\..\compat;..\..\..\compat\fnmatch;..\..\..\compat\regex;.\"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\porting.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\mozilla-sha1\sha1.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\archive.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\attr.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\blob.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\branch.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\bundle.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\cache-tree.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\cache.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\color.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\commit.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\csum-file.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\decorate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\delta.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diff.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diffcore.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\dir.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\exec_cmd.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\fetch-pack.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\fsck.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\git-compat-util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\graph.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\grep.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\hash.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\help.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\http.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\levenshtein.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\list-objects.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\ll-merge.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\log-tree.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\mailmap.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\merge-recursive.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\notes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\object.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack-refs.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack-revindex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\parse-options.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\patch-ids.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pkt-line.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\progress.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\quote.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\reachable.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\reflog-walk.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\refs.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\remote.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\rerere.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\revision.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\run-command.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\send-pack.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sha1-lookup.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shortlog.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sideband.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sigchain.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\strbuf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\string-list.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tag.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tar.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\thread-utils.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\transport.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tree-walk.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tree.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\unpack-trees.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\userdiff.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\utf8.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\walker.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\wt-status.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff-interface.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="compat"
+ >
+ <File
+ RelativePath="..\..\..\compat\basename.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\cygwin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\fnmatch\fnmatch.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\fnmatch\fnmatch.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\fopen.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\memmem.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\mingw.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\mingw.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\mkdtemp.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\mkstemps.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\pread.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\qsort.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\regex\regex.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\regex\regex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\setenv.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\snprintf.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\strcasestr.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\strlcpy.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\strtoumax.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\unsetenv.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\win32.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\win32mmap.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\compat\winansi.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="git"
+ >
+ <File
+ RelativePath="..\..\..\abspath.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\alias.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\alloc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\archive-tar.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\archive-zip.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\archive.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\attr.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\base85.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\bisect.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\blob.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\branch.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-add.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-annotate.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-apply.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-archive.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-bisect--helper.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-blame.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-branch.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-bundle.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-cat-file.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-check-attr.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-check-ref-format.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-checkout-index.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-checkout.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-clean.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-clone.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-commit-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-commit.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-config.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-count-objects.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-describe.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-diff-files.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-diff-index.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-diff-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-diff.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-fast-export.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-fetch--tool.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-fetch-pack.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-fetch.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-fmt-merge-msg.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-for-each-ref.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-fsck.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-gc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-grep.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-help.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-init-db.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-log.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-ls-files.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-ls-remote.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-ls-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-mailinfo.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-mailsplit.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-merge-base.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-merge-file.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-merge-ours.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-merge-recursive.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-merge.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-mktree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-mv.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-name-rev.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-pack-objects.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-pack-refs.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-prune-packed.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-prune.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-push.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-read-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-receive-pack.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-reflog.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-remote.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-rerere.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-reset.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-rev-list.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-rev-parse.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-revert.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-rm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-send-pack.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-shortlog.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-show-branch.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-show-ref.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-stripspace.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-symbolic-ref.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-tag.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-tar-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-unpack-objects.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-update-index.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-update-ref.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-upload-archive.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-verify-pack.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-verify-tag.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\builtin-write-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\bundle.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\cache-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\color.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\combine-diff.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\commit.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\config.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\connect.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\convert.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\copy.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\csum-file.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\ctype.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\date.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\decorate.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diff-delta.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diff-lib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diff-no-index.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diff.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diffcore-break.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diffcore-delta.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diffcore-order.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diffcore-pickaxe.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\diffcore-rename.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\dir.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\editor.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\entry.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\environment.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\exec_cmd.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\fsck.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\graph.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\grep.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\hash.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\help.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\ident.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\levenshtein.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\list-objects.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\ll-merge.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lockfile.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\log-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\mailmap.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\match-trees.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\merge-file.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\merge-recursive.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\merge-tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\name-hash.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\object.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack-check.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack-refs.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack-revindex.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pack-write.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pager.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\parse-options.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\patch-delta.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\patch-ids.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\path.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pkt-line.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\preload-index.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\pretty.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\progress.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\quote.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\reachable.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\read-cache.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\reflog-walk.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\refs.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\remote.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\rerere.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\revision.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\run-command.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\server-info.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\setup.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sha1-lookup.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sha1_file.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sha1_name.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shallow.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sideband.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\sigchain.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\strbuf.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\string-list.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\symlinks.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tag.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\thread-utils.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\trace.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\transport.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tree-diff.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tree-walk.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\tree.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\unpack-trees.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\usage.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\userdiff.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\utf8.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\walker.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\wrapper.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\write_or_die.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\ws.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\wt-status.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff-interface.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="xdiff"
+ >
+ <File
+ RelativePath="..\..\..\xdiff\xdiff.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xdiffi.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xdiffi.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xemit.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xemit.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xinclude.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xmacros.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xmerge.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xpatience.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xprepare.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xprepare.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xtypes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xutils.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\xdiff\xutils.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/compat/vcbuild/porting.c b/compat/vcbuild/porting.c
new file mode 100644
index 0000000..f9bd82d
--- /dev/null
+++ b/compat/vcbuild/porting.c
@@ -0,0 +1,13 @@
+#include "stdio.h"
+#include "STDARG.H"
+#include <string.h>
+#include "dirent.h"
+#include "unistd.h"
+
+int strcasecmp (const char *s1, const char *s2)
+{
+ int size1=strlen(s1);
+ int sisz2=strlen(s2);
+
+ return _strnicmp(s1,s2,sisz2>size1?sisz2:size1);
+}
\ No newline at end of file
diff --git a/compat/vcbuild/sys/param.h b/compat/vcbuild/sys/param.h
new file mode 100644
index 0000000..e69de29
diff --git a/compat/vcbuild/sys/socket.h b/compat/vcbuild/sys/socket.h
new file mode 100644
index 0000000..e69de29
diff --git a/compat/vcbuild/sys/time.h b/compat/vcbuild/sys/time.h
new file mode 100644
index 0000000..6ed82c0
--- /dev/null
+++ b/compat/vcbuild/sys/time.h
@@ -0,0 +1,21 @@
+#ifndef _UTIME_H_
+#define _UTIME_H_
+/*
+ * Structure used by _utime function.
+ */
+struct _utimbuf
+{
+ time_t actime; /* Access time */
+ time_t modtime; /* Modification time */
+};
+
+#ifndef _NO_OLDNAMES
+/* NOTE: Must be the same as _utimbuf above. */
+struct utimbuf
+{
+ time_t actime;
+ time_t modtime;
+};
+#endif /* Not _NO_OLDNAMES */
+
+#endif
diff --git a/compat/winansi.c b/compat/winansi.c
index 9217c24..6091138 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -3,7 +3,11 @@
*/
#include <windows.h>
+#ifdef _MSC_VER
+#include <stdio.h>
+#else
#include "../git-compat-util.h"
+#endif
/*
Functions to be wrapped:
@@ -310,9 +314,13 @@ static int winansi_vfprintf(FILE *stream, const char *format, va_list list)
if (!console)
goto abort;
+#ifndef _MSC_VER
va_copy(cp, list);
len = vsnprintf(small_buf, sizeof(small_buf), format, cp);
va_end(cp);
+#else
+ len= sizeof(small_buf) ;
+#endif
if (len > sizeof(small_buf) - 1) {
buf = malloc(len + 1);
diff --git a/git-compat-util.h b/git-compat-util.h
index 9f941e4..3b683e6 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -87,7 +87,7 @@
#include <assert.h>
#include <regex.h>
#include <utime.h>
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
#include <sys/wait.h>
#include <sys/poll.h>
#include <sys/socket.h>
diff --git a/help.c b/help.c
index 6c46d8b..a311241 100644
--- a/help.c
+++ b/help.c
@@ -126,8 +126,8 @@ static int is_executable(const char *name)
!S_ISREG(st.st_mode))
return 0;
-#ifdef __MINGW32__
- /* cannot trust the executable bit, peek into the file instead */
+#if defined(__MINGW32__) || defined(_MSC_VER)
+{ /* cannot trust the executable bit, peek into the file instead */
char buf[3] = { 0 };
int n;
int fd = open(name, O_RDONLY);
@@ -140,6 +140,7 @@ static int is_executable(const char *name)
st.st_mode |= S_IXUSR;
close(fd);
}
+}
#endif
return st.st_mode & S_IXUSR;
}
--git a/pager.c b/pager.c
index 4921843..28122c5 100644
--- a/pager.c
+++ b/pager.c
@@ -9,7 +9,7 @@
static int spawned_pager;
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
static void pager_preexec(void)
{
/*
@@ -70,7 +70,7 @@ void setup_pager(void)
pager_argv[2] = pager;
pager_process.argv = pager_argv;
pager_process.in = -1;
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
pager_process.preexec_cb = pager_preexec;
#endif
if (start_command(&pager_process))
diff --git a/run-command.c b/run-command.c
index ff3d8e2..1ea1c16 100644
--- a/run-command.c
+++ b/run-command.c
@@ -67,7 +67,7 @@ int start_command(struct child_process *cmd)
trace_argv_printf(cmd->argv, "trace: run_command:");
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
fflush(NULL);
cmd->pid = fork();
if (!cmd->pid) {
@@ -123,6 +123,7 @@ int start_command(struct child_process *cmd)
exit(127);
}
#else
+{
int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
const char **sargv = cmd->argv;
char **env = environ;
@@ -186,6 +187,7 @@ int start_command(struct child_process *cmd)
dup2(s1, 1), close(s1);
if (s2 >= 0)
dup2(s2, 2), close(s2);
+}
#endif
if (cmd->pid < 0) {
@@ -292,7 +294,8 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
return run_command(&cmd);
}
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#define __stdcall
static __stdcall unsigned run_thread(void *data)
{
struct async *async = data;
@@ -308,7 +311,7 @@ int start_async(struct async *async)
return error("cannot create pipe: %s", strerror(errno));
async->out = pipe_out[0];
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
/* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL);
@@ -337,7 +340,7 @@ int start_async(struct async *async)
int finish_async(struct async *async)
{
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
int ret = 0;
if (wait_or_whine(async->pid))
diff --git a/run-command.h b/run-command.h
index e345502..57a707b 100644
--- a/run-command.h
+++ b/run-command.h
@@ -79,7 +79,7 @@ struct async {
int (*proc)(int fd, void *data);
void *data;
int out; /* caller reads from here and closes it */
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
pid_t pid;
#else
HANDLE tid;
diff --git a/setup.c b/setup.c
index e3781b6..14e3ca7 100644
--- a/setup.c
+++ b/setup.c
@@ -41,7 +41,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
{
static char path[PATH_MAX];
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
if (!pfx || !*pfx || is_absolute_path(arg))
return arg;
memcpy(path, pfx, pfx_len);
--
1.6.4.msysgit.0
^ permalink raw reply related
* [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL
From: Brian Gernhardt @ 2009-08-15 16:46 UTC (permalink / raw)
To: Git List; +Cc: Junio C Hamano
The Makefile comment for NEEDS_SSL_WITH_CRYPTO says to define it "if
you need -lcrypto with -lssl (Darwin)." However, what it actually
does is add -lssl when you use -lcrypto and not the other way around.
However, libcrypto contains a majority of the ERR_* functions from
OpenSSL (at least on OS X) so we need it both ways.
So, add NEEDS_CRYPTO_WITH_SSL which adds -lcrypto to the OpenSSL link
flags and clarify the difference between it and NEEDS_SSL_WITH_CRYPTO.
---
After adding BLK_SHA1 to my config.mak, git-imap-send started giving me link
errors:
Undefined symbols:
"_ERR_get_error", referenced from:
_ssl_socket_perror in imap-send.o
"_ERR_error_string", referenced from:
_ssl_socket_perror in imap-send.o
Some investigation led me to the fact that BLK_SHA1 removes LIB_4_CRYPTO from
EXTLIBS. That let me find the missing functions in libcrypto. At first I
considered making NEEDS_SSL_WITH_CRYPTO add -lcrypto to the SSL build flags
but decided to go this route in case there are platforms that need it one way
around and not the other.
I've enabled this build option by default on Darwin but nowhere else. If you
can't build git-imap-send (with SSL) after enabling BLK_SHA1, your platform
may need this flag as well.
Makefile | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index f94fe05..bc745fb 100644
--- a/Makefile
+++ b/Makefile
@@ -99,7 +99,9 @@ all::
# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
# choice) has very fast version optimized for i586.
#
-# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
+# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
+#
+# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
#
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
#
@@ -714,6 +716,7 @@ ifeq ($(uname_S),SCO_SV)
TAR = gtar
endif
ifeq ($(uname_S),Darwin)
+ NEEDS_CRYPTO_WITH_SSL = YesPlease
NEEDS_SSL_WITH_CRYPTO = YesPlease
NEEDS_LIBICONV = YesPlease
ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
@@ -1023,6 +1026,9 @@ ifndef NO_OPENSSL
else
OPENSSL_LINK =
endif
+ ifdef NEEDS_CRYPTO_WITH_SSL
+ OPENSSL_LINK += -lcrypto
+ endif
else
BASIC_CFLAGS += -DNO_OPENSSL
MOZILLA_SHA1 = 1
--
1.6.4.244.ge5cd0
^ permalink raw reply related
* Re: Using VC build git (new patch)
From: Johannes Schindelin @ 2009-08-15 16:57 UTC (permalink / raw)
To: Frank Li; +Cc: git, msysGit
In-Reply-To: <1976ea660908150921n516178dbs2ce024ed729e2e02@mail.gmail.com>
Hi,
On Sun, 16 Aug 2009, Frank Li wrote:
> New patch.
A single monster patch?
Hmm.
Please understand that I will not review that unless it is split up into
nice little and reviewable chunks.
This diffstat does not let me expect well-defined changes, either, sorry:
builtin-fast-export.c | 1 +
compat/fnmatch/fnmatch.c | 2 +
compat/mingw.c | 68 ++-
compat/mingw.h | 21 +-
compat/regex/regex.c | 8 +-
compat/snprintf.c | 7 +-
compat/vcbuild/.gitignore | 3 +
compat/vcbuild/ReadMe | 13 +
compat/vcbuild/git/git.vcproj | 197 +++++
compat/vcbuild/include/dirent.h | 127 ++++
compat/vcbuild/include/unistd.h | 174 +++++
compat/vcbuild/libgit/libgit.vcproj | 1347 +++++++++++++++++++++++++++++++++++
compat/vcbuild/porting.c | 13 +
compat/vcbuild/sys/time.h | 21 +
compat/winansi.c | 8 +
git-compat-util.h | 2 +-
help.c | 5 +-
pager.c | 4 +-
run-command.c | 11 +-
run-command.h | 2 +-
setup.c | 2 +-
21 files changed, 2011 insertions(+), 25 deletions(-)
It still modifies mingw.c and mingw.h, even if it has been strongly
suggested to leave those alone.
It touches all kinds of files that appear to be completely unrelated to
Microsoft Visual C++.
Remember: breaking things for existing users (and changing something that
works for them quite well readily risks that) is not an option.
And the commit message does not even explain half of it...
Ciao,
Dscho
^ permalink raw reply
* Re: Using VC build git (new patch)
From: Johannes Schindelin @ 2009-08-15 17:29 UTC (permalink / raw)
To: Frank Li; +Cc: git, msysGit
In-Reply-To: <alpine.DEB.1.00.0908151851280.8306@pacific.mpi-cbg.de>
Hi,
On Sat, 15 Aug 2009, Johannes Schindelin wrote:
> A single monster patch?
>
> Hmm.
>
> Please understand that I will not review that unless it is split up into
> nice little and reviewable chunks.
Well, I try to improve.
So I had a look at your patch. The changes fall naturally into one of the
following categories:
- decl-after-statement fixes
- missing #include "git-compat-util.h"
- converting a K&R style function definition to modern C
- #undef's only needed for Microsoft Visual C++
- the addition of O_BINARY in the file modes
- disabling link() (why?)
- double-#define'ing stat (which puzzles me greatly)
- dummy #define'ing of a few compiler attributes
- adding _MSVC to a conditional to avoid #define'ing
SNPRINTF_SIZE_CORR yourself
- #define'ing several symbols without leading underscore to the
MS-specific version with a leading underscore
- implementing strcasecmp() in a misnamed file
- "fixing" the return value of winansi_vfprintf for Microsoft
Visual C++ (I think this fix is wrong)
- correctly adding a Visual C++-specific conditional to
git-compat-util.h, pager.c, run-command.c, run-command.h,
setup.c and help.c, although the latter five could use some
refactoring into git-compat-util.h
Maybe there is also room to change the MinGW-conditional into a
NO_TRUSTABLE_FILEMODE one
- adding several headers missing from Visual C++'s installation
- adding _huge_ .vcproj files (can they not be smaller?)
As you can see, there is a pretty natural way to split that huge patch
into chunks that most people on these lists can review easily, and that
would actually be a pleasure to look at.
Even better, there are a few fixes (the first three, if you ask me), which
are not even Windows-specific.
Further, I would like to suggest adding a header file compat/msvc.h which
contains all the #undef's and #define's necessary only for Visual C++, and
which can be #include'd from git-compat-util.h, to better separate your
work from the other platforms (who do not want those changes). That
should avoid those unwanted changes to mingw.c and mingw.h. You just have
to make sure that msvc.h is #include'd before mingw.h.
With these comments, I look forward to your next iteration.
Ciao,
Dscho
^ permalink raw reply
* git-svn bug report: %20 in http:// should translate to a space ' ' automatically
From: Mike Smullin @ 2009-08-15 17:48 UTC (permalink / raw)
To: Eric Wong; +Cc: git
Hello,
This one took me over an hour to figure out with the help of doener in
#git on irc.freenode.net:
(10:11:15) jeanrussou: i am using git-svn clone to checkout individual
directories from an svn repo as separate .git repos on my local hdd.
some of the git-svn clone attempts get all of svn repo history, this one
gets only the last commit. an svn log of the same path returns a history
of at least 5 commits. i only have the most recent one in my git log
after git svn clone. any idea why?
...
(10:18:37) charon: jeanrussou: git-svn only tracks svn rename/copy
operations that are "visible" to it, i.e., happen entirely within the
paths cloned
(10:18:53) charon: jeanrussou: try 'svn log -v' to see if the directory
was moved
(10:18:54) jeanrussou: charon: yes, i did move the path. is there a
workaround? can i tell git-svn the original path before the move, or
something?
(10:23:46) doener: jeanrussou: so what's the situation you have? Cloning
repo/foo and repo/foo/bar was repo/goo in the past?
(10:23:56) doener: jeanrussou: or cloning repo/foo which was repo/bar in
the past?
(10:24:59) jeanrussou: in the beginning there was
http://repo/projects/Client%20Name/Project, then over time it became
http://repo/projects/archive/Client%20Name/Project. i am now attempting
git-svn clone on the latter url
(10:25:28) jeanrussou: there were no changes to the project after it
went into archive
(10:25:36) jeanrussou: i believe this is why it appears to only be
grabbing the last commit (which was the move)
(10:25:49) doener: jeanrussou: if that was a direct rename from one to
the other, git-svn should be able to follow that
... (trying -T, also svn+ssh://) ... finally the cause is found ...
(11:27:49) jeanrussou: i wrap it in double-quotes and replace %20 with a
space ' ' and it works
(11:31:40) jeanrussou: oh if i just replace %20 with a space the http://
url works too
(11:31:48) doener: *lol*
(11:31:57) jeanrussou: dangit
(11:32:20) jeanrussou: thanks doener
(11:32:23) jeanrussou: u rock
(11:32:25) doener: you're welcome
(11:33:10) doener: too bad that the bug reports I found didn't have the
space issue, would likely have saved some time ;-)
(11:33:38) jeanrussou: ya we should make one
(11:34:01) jeanrussou: that would be cool if git-svn could unescape the
url encodings for http:// paths
(11:34:17) doener: well, the path could contain a literal %20
(11:34:46) doener: not very common, but I guess the "give me the plain
path, please" approach of git-svn is ok
(11:35:39) jeanrussou: ya i could see that with svn+ssh:// and file://
but with http:// its going over WebDAV and i'd have to read the RFCs but
it might even be an HTTP thing about accessing URLs that % is not valid
in URLs
(11:36:37) doener: yeah, those need to be escaped as %25 (IIRC). And
it's kinda weird that the one without -T works
(11:36:49) jeanrussou: o ya definitely. that too
(11:36:56) doener: so yeah, a bug report might be the right thing
(11:36:57) jeanrussou: thats what threw me off. i thought the url was
working because of that
(11:37:14) jeanrussou: okay cool lets see if i can find the git bug tracker
Hope this helps! :)
--
Respectfully,
Mike Smullin
Senior Web Systems Director
Smullin Design and Development, LLC
http://www.smullindesign.com
http://www.linkedin.com/in/mikesmullin
2112 E. Frontier St.
Eagle Mountain, Utah 84005
United States
toll-free: +1 800-819-7431
mobile: +1 801-652-5849
skype: smullindesign
^ permalink raw reply
* Re: git-svn bug report: %20 in http:// should translate to a space ' ' automatically
From: Björn Steinbrink @ 2009-08-15 18:16 UTC (permalink / raw)
To: Mike Smullin; +Cc: Eric Wong, git
In-Reply-To: <4A86F4DA.5090605@smullindesign.com>
On 2009.08.15 11:48:10 -0600, Mike Smullin wrote:
> Hello,
>
> This one took me over an hour to figure out with the help of doener
> in #git on irc.freenode.net:
[IRC log omitted]
To wrap that up:
1) git svn clone http://host/repo/path%20with%20spaces/foo/bar/goo
Works, but see below.
2) git svn clone -Tgoo http://host/repo/path%20with%20spaces/foo/bar
Fails.
3) git svn clone -Tgoo "http://host/repo/path with spaces/foo/bar"
Works.
In Mike's case, there was a rename from foo/goo to foo/bar/goo. 1) fails
to follow that rename, 2) just completely fails and 3) works and follows
the rename.
Cloning via http:// didn't provide any interesting error messages, but
cloning via svn+ssh:// showed:
For 1)
W: Ignoring error from SVN, path probably does not exist: (160013):
Filesystem has no item: File not found: revision 100, path
'/path with spaces/foo/bar"
For 2)
W: Ignoring error from SVN, path probably does not exist: (160013):
Filesystem has no item: File not found: revision 100, path
'/path%20with%20spaces/foo/bar"
So 2) somehow has the spaces escaped there, but 1) doesn't.
I guess that 1) has it right, and the rename detection just doesn't work
because the old name is outside of "url" for the svn-remote. And 2)
somehow gets it wrong, likely double-escaping the spaces or so. (I have
no idea...)
My totally uneducated guess is that git-svn fails to unescaped the path
when it splits it into the higher-level part for "url" and the rest of
it for "fetch".
HTH
Björn
^ permalink raw reply
* Re: [PATCH] add -p: do not attempt to coalesce mode changes
From: Junio C Hamano @ 2009-08-15 18:19 UTC (permalink / raw)
To: Thomas Rast; +Cc: Jeff King, Kirill Smelkov, git
In-Reply-To: <200908151635.24341.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> Hmm. I briefly considered worrying about futureproofing, but then
> decided it wasn't worth it since we also rely on
> coalesce_overlapping_hunks only being run over the hunks of a single
> file.
Thanks, all.
^ permalink raw reply
* Re: [PATCH] block-sha1/sha1.c: silence compiler complaints by casting void* to uintptr_t
From: Linus Torvalds @ 2009-08-15 18:43 UTC (permalink / raw)
To: Junio C Hamano
Cc: Brandon Casey, Johannes Schindelin, nico, git, Brandon Casey
In-Reply-To: <7v63cp22cc.fsf@alter.siamese.dyndns.org>
On Fri, 14 Aug 2009, Junio C Hamano wrote:
>
> From: Brandon Casey <drafnel@gmail.com>
> Date: Fri, 14 Aug 2009 17:52:15 -0500
> Subject: [PATCH] block-sha1/sha1.c: silence compiler complaints by casting void * to char *
>
> Some compilers produce errors when arithmetic is attempted on pointers to
> void. We want computations done on byte addresses, so cast them to char *
> to work them around.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Unnecessary outer parentheses, but ack anyway.
Linus
^ permalink raw reply
* [JGIT PATCH] Fix update of the refs cache when updating via a symbolic ref
From: Robin Rosenberg @ 2009-08-15 18:43 UTC (permalink / raw)
To: spearce; +Cc: git, stefan.lay, Robin Rosenberg
The branch pointed to by HEAD was lost in the refs cache, i.e. the
HEAD Ref was inserted into the cache with the the peeled ref as
key instead of HEAD. Then when asking for the peeled ref name HEAD
was returned.
This only happened when the ref name was a loose ref and not in
packed-refs at all, hence we test with an unborn branch, though an
existing loose (only) ref would show the same problem.
See http://bugs.eclipse.org/285991
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../tst/org/spearce/jgit/lib/RefUpdateTest.java | 61 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/RefDatabase.java | 2 +-
2 files changed, 62 insertions(+), 1 deletions(-)
I'm not posting the patch to bugzilla since this is bug in JGit and not EGit.
-- robin
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
index 8df8c2a..655e54e 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
@@ -298,6 +298,67 @@ public void testUpdateRefNoChange() throws IOException {
}
/**
+ * Test case originating from
+ * <a href="http://bugs.eclipse.org/285991">bug 285991</a>
+ *
+ * Make sure the in memory cache is updated properly after
+ * update of symref. This one did not fail because the
+ * ref was packed due to implementation issues.
+ *
+ * @throws Exception
+ */
+ public void testRefsCacheAfterUpdate() throws Exception {
+ // Do not use the defalt repo for this case.
+ Map<String, Ref> allRefs = db.getAllRefs();
+ ObjectId oldValue = db.resolve("HEAD");
+ ObjectId newValue = db.resolve("HEAD^");
+ // first make HEAD refer to loose ref
+ RefUpdate updateRef = db.updateRef(Constants.HEAD);
+ updateRef.setForceUpdate(true);
+ updateRef.setNewObjectId(newValue);
+ Result update = updateRef.update();
+ assertEquals(Result.FORCED, update);
+
+ // now update that ref
+ updateRef = db.updateRef(Constants.HEAD);
+ updateRef.setForceUpdate(true);
+ updateRef.setNewObjectId(oldValue);
+ update = updateRef.update();
+ assertEquals(Result.FAST_FORWARD, update);
+ allRefs = db.getAllRefs();
+ assertEquals("refs/heads/master", allRefs.get("refs/heads/master").getName());
+ assertEquals("refs/heads/master", allRefs.get("refs/heads/master").getOrigName());
+ assertEquals("refs/heads/master", allRefs.get("HEAD").getName());
+ assertEquals("HEAD", allRefs.get("HEAD").getOrigName());
+ }
+
+ /**
+ * Test case originating from
+ * <a href="http://bugs.eclipse.org/285991">bug 285991</a>
+ *
+ * Make sure the in memory cache is updated properly after
+ * update of symref.
+ *
+ * @throws Exception
+ */
+ public void testRefsCacheAfterUpdateLoosOnly() throws Exception {
+ // Do not use the defalt repo for this case.
+ Map<String, Ref> allRefs = db.getAllRefs();
+ ObjectId oldValue = db.resolve("HEAD");
+ db.writeSymref(Constants.HEAD, "refs/heads/newref");
+ RefUpdate updateRef = db.updateRef(Constants.HEAD);
+ updateRef.setForceUpdate(true);
+ updateRef.setNewObjectId(oldValue);
+ Result update = updateRef.update();
+ assertEquals(Result.NEW, update);
+ allRefs = db.getAllRefs();
+ assertEquals("refs/heads/newref", allRefs.get("HEAD").getName());
+ assertEquals("HEAD", allRefs.get("HEAD").getOrigName());
+ assertEquals("refs/heads/newref", allRefs.get("refs/heads/newref").getName());
+ assertEquals("refs/heads/newref", allRefs.get("refs/heads/newref").getOrigName());
+ }
+
+ /**
* Try modify a ref, but get wrong expected old value
*
* @throws IOException
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
index f7751c4..ba4b654 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -140,7 +140,7 @@ RefUpdate newUpdate(final String name) throws IOException {
void stored(final String origName, final String name, final ObjectId id, final long time) {
synchronized (this) {
- looseRefs.put(name, new Ref(Ref.Storage.LOOSE, origName, name, id));
+ looseRefs.put(name, new Ref(Ref.Storage.LOOSE, name, name, id));
looseRefsMTime.put(name, time);
setModified();
}
--
1.6.4.115.gc0eb0
^ permalink raw reply related
* Simplify '--prett=xyz' options
From: Linus Torvalds @ 2009-08-15 19:01 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
I keep on thinking that I can write
git log --format:'%aN: %s'
instead of using the long-form "--pretty=format:xyz' thing. And each time,
I curse myself for being stupid for forgetting the proper format.
And I'm tired of being stupid. So this patch makes me smart and
forward-thinking instead.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
Now I just need a patch to make me athletic and handsome.
commit.h | 1 +
pretty.c | 26 ++++++++++++++++----------
revision.c | 2 ++
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/commit.h b/commit.h
index ba9f638..cc4229b 100644
--- a/commit.h
+++ b/commit.h
@@ -68,6 +68,7 @@ struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
extern char *reencode_commit_message(const struct commit *commit,
const char **encoding_p);
extern void get_commit_format(const char *arg, struct rev_info *);
+extern int try_get_commit_format(const char *arg, struct rev_info *);
extern void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb,
enum date_mode dmode);
diff --git a/pretty.c b/pretty.c
index e5328da..97d36c5 100644
--- a/pretty.c
+++ b/pretty.c
@@ -19,7 +19,7 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma
rev->commit_format = CMIT_FMT_USERFORMAT;
}
-void get_commit_format(const char *arg, struct rev_info *rev)
+int try_get_commit_format(const char *arg, struct rev_info *rev)
{
int i;
static struct cmt_fmt_map {
@@ -36,14 +36,9 @@ void get_commit_format(const char *arg, struct rev_info *rev)
{ "oneline", 1, CMIT_FMT_ONELINE },
};
- rev->use_terminator = 0;
- if (!arg || !*arg) {
- rev->commit_format = CMIT_FMT_DEFAULT;
- return;
- }
if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');
- return;
+ return 1;
}
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
@@ -51,15 +46,26 @@ void get_commit_format(const char *arg, struct rev_info *rev)
if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
rev->use_terminator = 1;
rev->commit_format = cmt_fmts[i].v;
- return;
+ return 1;
}
}
if (strchr(arg, '%')) {
save_user_format(rev, arg, 1);
- return;
+ return 1;
}
- die("invalid --pretty format: %s", arg);
+ return 0;
+}
+
+void get_commit_format(const char *arg, struct rev_info *rev)
+{
+ rev->use_terminator = 0;
+ if (!arg || !*arg) {
+ rev->commit_format = CMIT_FMT_DEFAULT;
+ return;
+ }
+ if (!try_get_commit_format(arg, rev))
+ die("invalid --pretty format: %s", arg);
}
/*
diff --git a/revision.c b/revision.c
index 9f5dac5..181593f 100644
--- a/revision.c
+++ b/revision.c
@@ -1192,6 +1192,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if (!strcmp(arg, "--children")) {
revs->children.name = "children";
revs->limited = 1;
+ } else if (!strncmp(arg, "--", 2) && try_get_commit_format(arg+2, revs)) {
+ revs->verbose_header = 1;
} else {
int opts = diff_opt_parse(&revs->diffopt, argv, argc);
if (!opts)
^ permalink raw reply related
* Re: Simplify '--prett=xyz' options
From: Thomas Rast @ 2009-08-15 19:19 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <alpine.LFD.2.01.0908151156510.3162@localhost.localdomain>
Linus Torvalds wrote:
>
> I keep on thinking that I can write
>
> git log --format:'%aN: %s'
>
> instead of using the long-form "--pretty=format:xyz' thing. And each time,
> I curse myself for being stupid for forgetting the proper format.
>
> And I'm tired of being stupid. So this patch makes me smart and
> forward-thinking instead.
But we already have --format="%aN: %s" since these two commits:
commit 36407548a2825462a91b456755412a65fd611fc0
Author: Nanako Shiraishi <nanako3@lavabit.com>
Date: Tue Feb 24 18:59:15 2009 +0900
Give short-hands to --pretty=tformat:%formatstring
Allow --pretty="%h %s" (and --format="%h %s") as shorthand for an often
used option --pretty=tformat:"%h %s".
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit 3a4c1a5e212357c3df030b6713c75466694c2e77
Author: Nanako Shiraishi <nanako3@lavabit.com>
Date: Tue Feb 24 18:59:14 2009 +0900
Add --format that is a synonym to --pretty
Some people prefer to call the pretty-print styles "format", and get
annoyed to see "git log --format=short" fail. Introduce it as a synonym
to --pretty so that both can be used.
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Granted, it makes it equivalent to --pretty=tformat:foo, but isn't
tformat the better choice in many cases?
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: Simplify '--prett=xyz' options
From: Linus Torvalds @ 2009-08-15 19:50 UTC (permalink / raw)
To: Thomas Rast; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <200908152119.56606.trast@student.ethz.ch>
On Sat, 15 Aug 2009, Thomas Rast wrote:
>
> But we already have --format="%aN: %s" since these two commits:
Yeah. Junio pointed that out.
We also have --oneline, which I actually like (but it doesn't work like
--pretty=oneline - it also enables --abbrev-commit). But then we don't
have --fuller (which is what I usually want to use when I want to see
committer info).
And "format" takes ':' when with --pretty=, but '=' when alone. Which is
what made me not notice that it worked due to silly semantic changes.And
the confusion with tformat vs format is fundamental.
> Granted, it makes it equivalent to --pretty=tformat:foo, but isn't
> tformat the better choice in many cases?
Not really. Look at what happens with
git log --stat --pretty=format:%s
and then try tformat instead. 'tformat' is broken, as is our current
--format=%s.
In other words, all of that crud is totally illogical, and our "short
versions" (--oneline and --format=) were done entirely incorrectly (well,
--oneline probably has the _right_ semantics, and --pretty=oneline is just
wrong, but whatever).
Sadly, we can't fix those things well.
But here's a fixed version of my patch that gets rid of some problems.
And our current --format= thing really _is_ fundamentaly broken, as shown
by my example above. Making it work like 'tformat' was a bug. With this,
you can say
git log --tformat=%s
if you want the stupid tformat semantics.
[ Junio, I fixed that, so this is strictly "version 3" of the patch. Now
"--format=x" works like "--pretty=format:x" and if you want tformat
semantics, you need to say "--tformat=x")
That's why the test-cases got modified with this patch - we were
actually _testing_ for that idiotic behavior of --pretty=format:x being
different from --format=x ]
I would like to also make "--pretty=oneline" have the same abbrev-commit
semantics as "--oneline" has, but I didn't actually do that change.
Linus
---
commit.h | 1 +
pretty.c | 42 +++++++++++++++++++++++++++++-------------
revision.c | 9 +++++++--
t/t4202-log.sh | 14 +++++++-------
4 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/commit.h b/commit.h
index ba9f638..cc4229b 100644
--- a/commit.h
+++ b/commit.h
@@ -68,6 +68,7 @@ struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
extern char *reencode_commit_message(const struct commit *commit,
const char **encoding_p);
extern void get_commit_format(const char *arg, struct rev_info *);
+extern int try_get_commit_format(const char *arg, struct rev_info *);
extern void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb,
enum date_mode dmode);
diff --git a/pretty.c b/pretty.c
index e5328da..1a76320 100644
--- a/pretty.c
+++ b/pretty.c
@@ -19,7 +19,7 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma
rev->commit_format = CMIT_FMT_USERFORMAT;
}
-void get_commit_format(const char *arg, struct rev_info *rev)
+int try_get_commit_format(const char *arg, struct rev_info *rev)
{
int i;
static struct cmt_fmt_map {
@@ -36,30 +36,46 @@ void get_commit_format(const char *arg, struct rev_info *rev)
{ "oneline", 1, CMIT_FMT_ONELINE },
};
- rev->use_terminator = 0;
- if (!arg || !*arg) {
- rev->commit_format = CMIT_FMT_DEFAULT;
- return;
+ if (!prefixcmp(arg, "format")) {
+ if (arg[6] == ':' || arg[6] == '=') {
+ save_user_format(rev, arg+7, 0);
+ return 1;
+ }
}
- if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
- save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');
- return;
+ if (!prefixcmp(arg, "tformat")) {
+ if (arg[7] == ':' || arg[7] == '=') {
+ save_user_format(rev, arg+8, 1);
+ return 1;
+ }
}
+
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
!strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
rev->use_terminator = 1;
rev->commit_format = cmt_fmts[i].v;
- return;
+ return 1;
}
}
- if (strchr(arg, '%')) {
- save_user_format(rev, arg, 1);
+
+ return 0;
+}
+
+void get_commit_format(const char *arg, struct rev_info *rev)
+{
+ rev->use_terminator = 0;
+ if (!arg || !*arg) {
+ rev->commit_format = CMIT_FMT_DEFAULT;
return;
}
-
- die("invalid --pretty format: %s", arg);
+ if (!try_get_commit_format(arg, rev)) {
+ if (strchr(arg, '%')) {
+ save_user_format(rev, arg, 0);
+ return;
+ }
+ die("invalid --pretty format: %s", arg);
+ }
}
/*
diff --git a/revision.c b/revision.c
index 9f5dac5..bdace8b 100644
--- a/revision.c
+++ b/revision.c
@@ -1123,7 +1123,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if (!strcmp(arg, "--pretty")) {
revs->verbose_header = 1;
get_commit_format(arg+8, revs);
- } else if (!prefixcmp(arg, "--pretty=") || !prefixcmp(arg, "--format=")) {
+ } else if (!prefixcmp(arg, "--pretty=")) {
revs->verbose_header = 1;
get_commit_format(arg+9, revs);
} else if (!strcmp(arg, "--oneline")) {
@@ -1194,8 +1194,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->limited = 1;
} else {
int opts = diff_opt_parse(&revs->diffopt, argv, argc);
- if (!opts)
+ if (!opts) {
+ if (!strncmp(arg, "--", 2) && try_get_commit_format(arg+2, revs)) {
+ revs->verbose_header = 1;
+ return 1;
+ }
unkv[(*unkc)++] = arg;
+ }
return opts;
}
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 48e0088..2f1a5a5 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -44,13 +44,6 @@ test_expect_success 'pretty' '
test_cmp expect actual
'
-printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
-test_expect_success 'pretty (tformat)' '
-
- git log --pretty="tformat:%s" > actual &&
- test_cmp expect actual
-'
-
test_expect_success 'pretty (shortcut)' '
git log --pretty="%s" > actual &&
@@ -63,6 +56,13 @@ test_expect_success 'format' '
test_cmp expect actual
'
+printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
+test_expect_success 'pretty (tformat)' '
+
+ git log --pretty="tformat:%s" > actual &&
+ test_cmp expect actual
+'
+
cat > expect << EOF
804a787 sixth
394ef78 fifth
^ permalink raw reply related
* Re: Linus' sha1 is much faster!
From: Bryan Donlan @ 2009-08-15 20:02 UTC (permalink / raw)
To: Pádraig Brady
Cc: Bug-coreutils, Linus Torvalds, Git Mailing List, Brandon Casey,
Junio C Hamano, Nicolas Pitre
In-Reply-To: <4A85F270.20703@draigBrady.com>
2009/8/14 Pádraig Brady <P@draigbrady.com>:
> I've noticed before that coreutils hashing utils
> were a little behind in performance, but was prompted
> to look at it again when I noticed the recently
> updated sha1 implementation in git:
> http://git.kernel.org/?p=git/git.git;a=history;f=block-sha1;h=d3121f7;hb=pu
>
> Testing that with the attached program which I wrote
> in a couple of mins to try and match sha1sum's system calls
> shows that it's around 33% faster, as shown below:
>
> $ gcc $(rpm -q --qf="%{OPTFLAGS}\n" coreutils) linus-sha1.c sha1.c -o linus-sha1
>
> $ time ./linus-sha1 300MB_file
> df1e19e245fee4f53087b50ef953ca2c8d1644d7 300MB_file
> real 0m2.742s
> user 0m2.516s
> sys 0m0.206s
>
> $ time ~/git/coreutils/src/sha1sum 300MB_file
> df1e19e245fee4f53087b50ef953ca2c8d1644d7 300MB_file
>
> real 0m4.166s
> user 0m3.846s
> sys 0m0.298s
>
> So, could we use that code in coreutils?
> Think of all the dead fish it would save.
coreutils is licensed under GPLv3, and git under GPLv2 (only), so
you'd need permission from all contributors to the implementation in
order to relicense under GPLv3. A quick grep of the history suggests
these contributors to be:
Brandon Casey <drafnel@gmail.com>
Junio C Hamano <gitster@pobox.com>
Linus Torvalds <torvalds@linux-foundation.org>
Nicolas Pitre <nico@cam.org>
(adding these people to the CC list)
Additionally, it was originally based on the code in
mozilla-sha1/sha1.c, but that contains a license grant allowing it to
be used under GPLv2 /or later/, so if GPLv3 relicensing is enough it
shouldn't be necessary to get in contact with the original author.
However if the FSF requires copyright assignment to accept the new
implementation, it will be necessary to track down contributors to the
original mozilla-sha1/sha1.c as well.
Note that I'm not a lawyer, so there might be other roadblocks etc to
this as well, etc :)
^ permalink raw reply
* Re: Linus' sha1 is much faster!
From: John Tapsell @ 2009-08-15 20:12 UTC (permalink / raw)
To: Bryan Donlan
Cc: Pádraig Brady, Bug-coreutils, Linus Torvalds,
Git Mailing List, Brandon Casey, Junio C Hamano, Nicolas Pitre
In-Reply-To: <3e8340490908151302y33a97d50t38ad0a8a788f1cee@mail.gmail.com>
2009/8/15 Bryan Donlan <bdonlan@gmail.com>:
> coreutils is licensed under GPLv3, and git under GPLv2 (only), so
> you'd need permission from all contributors to the implementation in
> order to relicense under GPLv3. A quick grep of the history suggests
> these contributors to be:
X11 also requires a fast SHA1 implementation. It uses this to check
if two pixmaps are the same. So it would be really nice to relicense
under a liberal enough license that xorg can use it.
John
^ 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