Skip to content

Commit

Permalink
Merge branch 'master' into sp/mmap
Browse files Browse the repository at this point in the history
* master:
  Documentation/config.txt (and repo-config manpage): mark-up fix.
  Teach Git how to parse standard power of 2 suffixes.
  Use /dev/null for update hook stdin.
  Redirect update hook stdout to stderr.
  Remove unnecessary argc parameter from run_command_v.
  Automatically detect a bare git repository.
  Replace "GIT_DIR" with GIT_DIR_ENVIRONMENT.
  Use PATH_MAX constant for --bare.
  Force core.filemode to false on Cygwin.
  Fix formatting for urls section of fetch, pull, and push manpages
  Fix yet another subtle xdl_merge() bug
  i18n: drop "encoding" header in the output after re-coding.
  commit-tree: cope with different ways "utf-8" can be spelled.
  Move commit reencoding parameter parsing to revision.c
  Documentation: minor rewording for git-log and git-show pages.
  Documentation: i18n commit log message notes.
  t3900: test log --encoding=none
  commit re-encoding: fix confusion between no and default conversion.
  • Loading branch information
Junio C Hamano committed Dec 31, 2006
2 parents 2c039da + a862f97 commit 76d4e07
Show file tree
Hide file tree
Showing 27 changed files with 321 additions and 84 deletions.
14 changes: 7 additions & 7 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ core.logAllRefUpdates::
only when the file exists. If this configuration
variable is set to true, missing "$GIT_DIR/logs/<ref>"
file is automatically created for branch heads.

This information can be used to determine what commit
was the tip of a branch "2 days ago".

This value is true by default in a repository that has
a working directory associated with it, and false by
default in a bare repository.
+
This information can be used to determine what commit
was the tip of a branch "2 days ago".
+
This value is true by default in a repository that has
a working directory associated with it, and false by
default in a bare repository.

core.repositoryFormatVersion::
Internal variable identifying the repository format and layout
Expand Down
5 changes: 5 additions & 0 deletions Documentation/git-commit-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ Your parents must have hated you!::
Your sysadmin must hate you!::
The password(5) name field is longer than a giant static buffer.

Discussion
----------

include::i18n.txt[]

See Also
--------
gitlink:git-write-tree[1]
Expand Down
5 changes: 5 additions & 0 deletions Documentation/git-commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ should be recorded as a single commit. In fact, the command
refuses to run when given pathnames (but see `-i` option).


DISCUSSION
----------

include::i18n.txt[]

ENVIRONMENT VARIABLES
---------------------
The command specified by either the VISUAL or EDITOR environment
Expand Down
10 changes: 9 additions & 1 deletion Documentation/git-log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ include::pretty-formats.txt[]
Limits the number of commits to show.

<since>..<until>::
Show only commits between the named two commits.
Show only commits between the named two commits. When
either <since> or <until> is omitted, it defaults to
`HEAD`, i.e. the tip of the current branch.

-p::
Show the change the commit introduces in a patch form.
Expand Down Expand Up @@ -63,6 +65,12 @@ git log -r --name-status release..test::
in the "release" branch, along with the list of paths
each commit modifies.

Discussion
----------

include::i18n.txt[]


Author
------
Written by Linus Torvalds <torvalds@osdl.org>
Expand Down
5 changes: 4 additions & 1 deletion Documentation/git-repo-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ OPTIONS
git-repo-config will ensure that the output is "true" or "false"

--int::
git-repo-config will ensure that the output is a simple decimal number
git-repo-config will ensure that the output is a simple
decimal number. An optional value suffix of 'k', 'm', or 'g'
in the config file will cause the value to be multiplied
by 1024, 1048576, or 1073741824 prior to output.


ENVIRONMENT
Expand Down
1 change: 1 addition & 0 deletions Documentation/git-rev-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SYNOPSIS
[ \--stdin ]
[ \--topo-order ]
[ \--parents ]
[ \--encoding[=<encoding>] ]
[ \--(author|committer|grep)=<pattern> ]
[ [\--objects | \--objects-edge] [ \--unpacked ] ]
[ \--pretty | \--header ]
Expand Down
15 changes: 11 additions & 4 deletions Documentation/git-show.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ This manual page describes only the most frequently used options.

OPTIONS
-------
<commitid>::
ID of the commit to show.
<object>::
The name of the object to show.

include::pretty-formats.txt[]

Expand All @@ -40,7 +40,8 @@ EXAMPLES
--------

git show v1.0.0::
Shows the tag `v1.0.0`.
Shows the tag `v1.0.0`, along with the object the tags
points at.

git show v1.0.0^{tree}::
Shows the tree pointed to by the tag `v1.0.0`.
Expand All @@ -54,10 +55,16 @@ git show master:Makefile master:t/Makefile
Concatenates the contents of said Makefiles in the head
of the branch `master`.

Discussion
----------

include::i18n.txt[]

Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
Junio C Hamano <junkio@cox.net>
Junio C Hamano <junkio@cox.net>. Significantly enhanced by
Johannes Schindelin <Johannes.Schindelin@gmx.de>.


Documentation
Expand Down
57 changes: 57 additions & 0 deletions Documentation/i18n.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
At the core level, git is character encoding agnostic.

- The pathnames recorded in the index and in the tree objects
are treated as uninterpreted sequences of non-NUL bytes.
What readdir(2) returns are what are recorded and compared
with the data git keeps track of, which in turn are expected
to be what lstat(2) and creat(2) accepts. There is no such
thing as pathname encoding translation.

- The contents of the blob objects are uninterpreted sequence
of bytes. There is no encoding translation at the core
level.

- The commit log messages are uninterpreted sequence of non-NUL
bytes.

Although we encourage that the commit log messages are encoded
in UTF-8, both the core and git Porcelain are designed not to
force UTF-8 on projects. If all participants of a particular
project find it more convenient to use legacy encodings, git
does not forbid it. However, there are a few things to keep in
mind.

. `git-commit-tree` (hence, `git-commit` which uses it) issues
an warning if the commit log message given to it does not look
like a valid UTF-8 string, unless you explicitly say your
project uses a legacy encoding. The way to say this is to
have core.commitencoding in `.git/config` file, like this:
+
------------
[core]
commitencoding = ISO-8859-1
------------
+
Commit objects created with the above setting record the value
of `core.commitencoding` in its `encoding` header. This is to
help other people who look at them later. Lack of this header
implies that the commit log message is encoded in UTF-8.

. `git-log`, `git-show` and friends looks at the `encoding`
header of a commit object, and tries to re-code the log
message into UTF-8 unless otherwise specified. You can
specify the desired output encoding with
`core.logoutputencoding` in `.git/config` file, like this:
+
------------
[core]
logoutputencoding = ISO-8859-1
------------
+
If you do not have this configuration variable, the value of
`core.commitencoding` is used instead.

Note that we deliberately chose not to re-code the commit log
message when a commit is made to force UTF-8 at the commit
object level, because re-coding to UTF-8 is not necessarily a
reversible operation.
7 changes: 7 additions & 0 deletions Documentation/pretty-formats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ displayed in full, regardless of whether --abbrev or
--no-abbrev are used, and 'parents' information show the
true parent commits, without taking grafts nor history
simplification into account.

--encoding[=<encoding>]::
The commit objects record the encoding used for the log message
in their encoding header; this option can be used to tell the
command to re-code the commit log message in the encoding
preferred by the user. For non plumbing commands this
defaults to UTF-8.
23 changes: 16 additions & 7 deletions Documentation/urls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ In addition to the above, as a short-hand, the name of a
file in `$GIT_DIR/remotes` directory can be given; the
named file should be in the following format:

URL: one of the above URL format
Push: <refspec>
Pull: <refspec>
------------
URL: one of the above URL format
Push: <refspec>
Pull: <refspec>
------------

Then such a short-hand is specified in place of
<repository> without <refspec> parameters on the command
Expand All @@ -54,10 +56,12 @@ be specified for additional branch mappings.
Or, equivalently, in the `$GIT_DIR/config` (note the use
of `fetch` instead of `Pull:`):

------------
[remote "<remote>"]
url = <url>
push = <refspec>
fetch = <refspec>
------------

The name of a file in `$GIT_DIR/branches` directory can be
specified as an older notation short-hand; the named
Expand All @@ -68,10 +72,15 @@ name of remote head (URL fragment notation).
without the fragment is equivalent to have this in the
corresponding file in the `$GIT_DIR/remotes/` directory.

URL: <url>
Pull: refs/heads/master:<remote>
------------
URL: <url>
Pull: refs/heads/master:<remote>
------------


while having `<url>#<head>` is equivalent to

URL: <url>
Pull: refs/heads/<head>:<remote>
------------
URL: <url>
Pull: refs/heads/<head>:<remote>
------------
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ all:
# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
# generally faster on your platform than accessing the working directory.
#
# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
# the executable mode bit, but doesn't really do so.
#
# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
#
# Define NO_SOCKADDR_STORAGE if your platform does not have struct
Expand Down Expand Up @@ -361,6 +364,7 @@ ifeq ($(uname_O),Cygwin)
NEEDS_LIBICONV = YesPlease
NO_C99_FORMAT = YesPlease
NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
# There are conflicting reports about this.
# On some boxes NO_MMAP is needed, and not so elsewhere.
# Try commenting this out if you suspect MMAP is more efficient
Expand Down Expand Up @@ -521,6 +525,9 @@ endif
ifdef NO_FAST_WORKING_DIRECTORY
BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
endif
ifdef NO_TRUSTABLE_FILEMODE
BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
endif
ifdef NO_IPV6
BASIC_CFLAGS += -DNO_IPV6
endif
Expand Down
3 changes: 1 addition & 2 deletions builtin-commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
}

/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = (!git_commit_encoding ||
!strcmp(git_commit_encoding, "utf-8"));
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);

init_buffer(&buffer, &size);
add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1));
Expand Down
15 changes: 11 additions & 4 deletions builtin-init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/"
#endif

#ifdef NO_TRUSTABLE_FILEMODE
#define TEST_FILEMODE 0
#else
#define TEST_FILEMODE 1
#endif

static void safe_create_dir(const char *dir, int share)
{
if (mkdir(dir, 0777) < 0) {
Expand Down Expand Up @@ -175,6 +181,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
struct stat st1;
char repo_version_string[10];
int reinit;
int filemode;

if (len > sizeof(path)-50)
die("insane git directory %s", git_dir);
Expand Down Expand Up @@ -236,14 +243,14 @@ static int create_default_files(const char *git_dir, const char *template_path)
strcpy(path + len, "config");

/* Check filemode trustability */
if (!lstat(path, &st1)) {
filemode = TEST_FILEMODE;
if (TEST_FILEMODE && !lstat(path, &st1)) {
struct stat st2;
int filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
!lstat(path, &st2) &&
st1.st_mode != st2.st_mode);
git_config_set("core.filemode",
filemode ? "true" : "false");
}
git_config_set("core.filemode", filemode ? "true" : "false");

/* Enable logAllRefUpdates if a working tree is attached */
if (!is_bare_git_dir(git_dir))
Expand Down
2 changes: 1 addition & 1 deletion builtin-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static int do_push(const char *repo)
argv[dest_argc] = NULL;
if (verbose)
fprintf(stderr, "Pushing to %s\n", dest);
err = run_command_v(argc, argv);
err = run_command_v(argv);
if (!err)
continue;
switch (err) {
Expand Down
47 changes: 47 additions & 0 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,48 @@ static char *get_header(const struct commit *commit, const char *key)
}
}

static char *replace_encoding_header(char *buf, char *encoding)
{
char *encoding_header = strstr(buf, "\nencoding ");
char *end_of_encoding_header;
int encoding_header_pos;
int encoding_header_len;
int new_len;
int need_len;
int buflen = strlen(buf) + 1;

if (!encoding_header)
return buf; /* should not happen but be defensive */
encoding_header++;
end_of_encoding_header = strchr(encoding_header, '\n');
if (!end_of_encoding_header)
return buf; /* should not happen but be defensive */
end_of_encoding_header++;

encoding_header_len = end_of_encoding_header - encoding_header;
encoding_header_pos = encoding_header - buf;

if (is_encoding_utf8(encoding)) {
/* we have re-coded to UTF-8; drop the header */
memmove(encoding_header, end_of_encoding_header,
buflen - (encoding_header_pos + encoding_header_len));
return buf;
}
new_len = strlen(encoding);
need_len = new_len + strlen("encoding \n");
if (encoding_header_len < need_len) {
buf = xrealloc(buf, buflen + (need_len - encoding_header_len));
encoding_header = buf + encoding_header_pos;
end_of_encoding_header = encoding_header + encoding_header_len;
}
memmove(end_of_encoding_header + (need_len - encoding_header_len),
end_of_encoding_header,
buflen - (encoding_header_pos + encoding_header_len));
memcpy(encoding_header + 9, encoding, strlen(encoding));
encoding_header[9 + new_len] = '\n';
return buf;
}

static char *logmsg_reencode(const struct commit *commit)
{
char *encoding;
Expand All @@ -633,13 +675,18 @@ static char *logmsg_reencode(const struct commit *commit)
: git_commit_encoding);

if (!output_encoding)
output_encoding = "utf-8";
else if (!*output_encoding)
return NULL;
encoding = get_header(commit, "encoding");
if (!encoding || !strcmp(encoding, output_encoding)) {
free(encoding);
return NULL;
}
out = reencode_string(commit->buffer, output_encoding, encoding);
if (out)
out = replace_encoding_header(out, output_encoding);

free(encoding);
if (!out)
return NULL;
Expand Down
Loading

0 comments on commit 76d4e07

Please sign in to comment.