Commit Graph

6763 Commits

Author SHA1 Message Date
Vicent Marti
5ca410b9a9 Merge pull request #2283 from phkelley/win32_fs
Win32: UTF-8 <-> WCHAR conversion overhaul
2014-04-23 07:13:49 -07:00
Philip Kelley
7110000dd5 React to feedback for UTF-8 <-> WCHAR and reparse work 2014-04-23 09:23:50 -04:00
Vicent Marti
5b58d6f78c Merge pull request #2289 from libgit2/rb/note-git-diff-index-behavior
Some doc and examples/diff.c changes
2014-04-23 03:21:05 -07:00
Russell Belfer
37da368545 Make checkout match diff for untracked/ignored dir
When diff finds an untracked directory, it emulates Git behavior
by looking inside the directory to see if there are any untracked
items inside it. If there are only ignored items inside the dir,
then diff considers it ignored, even if there is no direct ignore
rule for it.

Checkout was not copying this behavior - when it found an untracked
directory, it just treated it as untracked.  Unfortunately, when
combined with GIT_CHECKOUT_REMOVE_UNTRACKED, this made is seem that
checkout (and stash, which uses checkout) was removing ignored
items when you had only asked it to remove untracked ones.

This commit moves the logic for advancing past an untracked dir
while scanning for non-ignored items into an iterator helper fn,
and uses that for both diff and checkout.
2014-04-22 21:51:54 -07:00
Edward Thomson
e349ed500b patch: emit binary patches (optionally) 2014-04-22 19:08:21 -05:00
Russell Belfer
3c1aa4c110 Failing test for stashing a buried ignored file 2014-04-22 15:23:43 -07:00
Russell Belfer
24d17de255 Make stash and checkout ignore contained repos
To emulate git, stash should not remove untracked git repositories
inside the parent repo, and checkout's REMOVE_UNTRACKED should
also skip over these items.

`git stash` actually prints a warning message for these items.
That should be possible with a checkout notify callback if you
wanted to, although it would require a bit of extra logic as things
are at the moment.
2014-04-22 15:23:43 -07:00
Russell Belfer
e60883c82f Replace math fns with simpler integer math 2014-04-22 12:59:31 -07:00
Russell Belfer
8d09efa24e Use git_diff_get_stats in example/diff + refactor
This takes the `--stat` and related example options in the example
diff.c program and converts them to use the `git_diff_get_stats`
API which nicely formats stats for you.

I went to add bar-graph scaling to the stats formatter and noticed
that the `git_diff_stats` structure was holding on to all of the
`git_patch` objects.  Unfortunately, each of these objects keeps
the full text of the diff in memory, so this is very expensive.  I
ended up modifying `git_diff_stats` to keep just the data that it
needs to keep and allowed it to release the patches.  Then, I added
width scaling to the output on top of that.

In making the diff example program match 'git diff' output, I ended
up removing an newline from the sumamry output which I then had to
compensate for in the email formatting to match the expectations.

Lastly, I went through and refactored the tests to use a couple of
helper functions and reduce the overall amount of code there.
2014-04-22 12:33:27 -07:00
Russell Belfer
12e422a056 Some doc and examples/diff.c changes
I was playing with "git diff-index" and wanted to be able to
emulate that behavior a little more closely with the diff example.

Also, I wanted to play with running `git_diff_tree_to_workdir`
directly even though core Git doesn't exactly have the equivalent,
so I added a command line option for that and tweaked some other
things in the example code.

This changes a minor output thing in that the "raw" print helper
function will no longer add ellipses (...) if the OID is not
actually abbreviated.
2014-04-22 09:17:29 -07:00
Vicent Marti
a32d684f86 Merge pull request #2282 from libgit2/cmn/remote-easier-bind
A few niceties for binding authors
2014-04-22 15:07:18 +02:00
Carlos Martín Nieto
bc0a619867 transports: allow the creds callback to say it doesn't exist
Allow the credentials callback to return GIT_PASSTHROUGH to make the
transports code behave as though none was set.

This should make it easier for bindings to behave closer to the C code
when there is no credentials callback set at their level.
2014-04-22 14:34:26 +02:00
Carlos Martín Nieto
2efd7df6b1 remote: provide read access to the callback structure
This should make it easier for bindings to dynamically override their
own callbacks.
2014-04-22 14:32:19 +02:00
Vicent Marti
dac95e4aa3 Merge pull request #2287 from libgit2/rb/moar-coverity-fixes
Fix some issues from the last Coverity scan
2014-04-22 11:04:35 +02:00
Vicent Marti
2e609e2931 Merge pull request #2286 from libgit2/rb/fix-reset-staged-delete
Fix reset for staged deletes
2014-04-22 11:03:42 +02:00
Edward Thomson
65477db166 Handle win32 reparse points properly 2014-04-22 00:28:27 -04:00
Russell Belfer
17ef678ca5 Fix some coverity-found issues 2014-04-21 11:55:57 -07:00
Russell Belfer
bd101a7eca Fix reset for staged deletes 2014-04-21 11:54:54 -07:00
Jacques Germishuys
f70cfd34f5 Verify update_tips callbacks in push test cases 2014-04-21 19:38:34 +02:00
Russell Belfer
28750a7d98 Merge pull request #2275 from jacquesg/apple-warning
Check for compiler flag support instead of checking for a platform
2014-04-21 09:50:43 -07:00
Jacques Germishuys
321d377a6a Fire update_tips callback also for pushes. 2014-04-21 17:28:03 +02:00
Carlos Martín Nieto
7839931019 attrcache: fix use-after-free
Reported by coverity.
2014-04-21 16:38:52 +02:00
Jacques Germishuys
8b686b318b Correct argument order of git__calloc() 2014-04-21 16:29:41 +02:00
Jacques Germishuys
be6996b792 It is safe to free() a NULL pointer 2014-04-21 16:29:41 +02:00
Carlos Martín Nieto
a15d3537bb sysdir: free the path if we cannot find the file
Returning an error cleared the buf, but this operation does not free the
memory associated with it. Use git_buf_free() instead.
2014-04-21 15:48:05 +02:00
Jacques Germishuys
48e60ae75e Don't redefine the same callback types, their signatures may change 2014-04-21 11:28:49 +02:00
Jacques Germishuys
98020d3a73 Rename progress callback to sideband_progress 2014-04-21 10:55:37 +02:00
Jacques Germishuys
4f62163ead Check the return codes of remote callbacks.
The user may have requested that the operation be cancelled.
2014-04-21 10:24:16 +02:00
Jacques Germishuys
9effa2fb72 Fire progress callbacks also for pushes.
It's not very useful to only know that a pre-receive hook has declined
a push, you probably want to know why.
2014-04-20 22:06:45 +02:00
Philip Kelley
c2c8161541 Win32: UTF-8 <-> WCHAR conversion overhaul 2014-04-19 21:50:44 -04:00
Jacques Germishuys
5c8d5eac35 Introduce AddCFlagIfSupported CMake macro 2014-04-19 23:07:50 +02:00
Vicent Marti
bfc50f83f8 Merge pull request #2273 from jacquesg/ssh-interactive
Add support for SSH keyboard-interactive authentication
2014-04-19 18:59:09 +02:00
Vicent Marti
7b0f8ba9a8 Merge pull request #2279 from libgit2/rb/moar-eegnöre-fîxés
Fix several ignore and attribute file behavior bugs
2014-04-19 13:05:32 +02:00
Russell Belfer
ac16bd0a94 Minor fixes
Only apply LEADING_DIR pattern munging to patterns in ignore and
attribute files, not to pathspecs used to select files to operate
on.  Also, allow internal macro definitions to be evaluated before
loading all external ones (important so that external ones can
make use of internal `binary` definition).
2014-04-18 15:45:59 -07:00
Russell Belfer
916fcbd617 Fix ignore difference from git with trailing /*
Ignore patterns that ended with a trailing '/*' were still needing
to match against another actual '/' character in the full path.
This is not the same behavior as core Git.

Instead, we strip a trailing '/*' off of any patterns that were
matching and just take it to imply the FNM_LEADING_DIR behavior.
2014-04-18 14:42:40 -07:00
Russell Belfer
e3a2a04cef Preload attribute files that may contain macros
There was a latent bug where files that use macro definitions
could be parsed before the macro definitions were loaded.  Because
of attribute file caching, preloading files that are going to be
used doesn't add a significant amount of overhead, so let's always
preload any files that could contain macros before we assemble the
actual vector of files to scan for attributes.
2014-04-18 14:29:58 -07:00
Jacques Germishuys
a622ff17a1 Only zero sensitive information on destruction (and memory actually allocated by us) 2014-04-18 20:09:58 +02:00
Russell Belfer
50e46d6018 Cleanup tests with helper functions 2014-04-18 10:58:01 -07:00
Russell Belfer
6a0956e504 Pop ignore only if whole relative path matches
When traversing the directory structure, the iterator pushes and
pops ignore files using a vector.  Some directories don't have
ignore files, so it uses a path comparison to decide when it is
right to actually pop the last ignore file.  This was only
comparing directory suffixes, though, so a subdirectory with the
same name as a parent could result in the parent's .gitignore
being popped off the list ignores too early.  This changes the
logic to compare the entire relative path of the ignore file.
2014-04-18 10:32:35 -07:00
Jacques Germishuys
364ef52881 Only disable deprecation warnings on Apple for OpenSSL 2014-04-18 19:13:18 +02:00
Jacques Germishuys
c6cd3f8bde Use CHECK_C_COMPILER_FLAG to determine if the compiler supports a flag
This simplifies platform/compiler dependent checks where we optionally
enable features or disable warnings.
2014-04-18 19:09:47 +02:00
Jacques Germishuys
48ce93e08f Fix inconsistent use of lower-case and upper-case names for macros 2014-04-18 19:09:47 +02:00
Russell Belfer
386777fd0d Merge pull request #2213 from ethomson/safecrlf
Introduce core.safecrlf handling
2014-04-18 09:26:38 -07:00
Jacques Germishuys
043112dc1c Replace void * with proper callback types 2014-04-18 17:58:25 +02:00
Jacques Germishuys
8ec0a55273 Make git_cred_ssh_custom_new() naming more consistent 2014-04-18 17:58:25 +02:00
Jacques Germishuys
478408c010 Introduce git_cred_ssh_interactive_new()
This allows for keyboard-interactive based SSH authentication
2014-04-18 17:58:25 +02:00
Vicent Marti
3c69bebc1c Merge pull request #2274 from libgit2/cmn/ssh-expect-username
cred: tighten username rules
2014-04-18 17:47:36 +02:00
Carlos Martín Nieto
bd270b70f9 cred: tighten username rules
The ssh-specific credentials allow the username to be missing. The idea
being that the ssh transport will then use the username provided in the
url, if it's available. There are two main issues with this.

The credential callback already knows what username was provided by the
url and needs to figure out whether it wants to ask the user for it or
it can reuse it, so passing NULL as the username means the credential
callback is suspicious.

The username provided in the url is not in fact used by the
transport. The only time it even considers it is for the user/pass
credential, which asserts the existence of a username in its
constructor. For the ssh-specific ones, it passes in the username stored
in the credential, which is NULL. The libssh2 macro we use runs strlen()
against this value (which is no different from what we would be doing
ourselves), so we then crash.

As the documentation doesn't suggest to leave out the username, assert
the need for a username in the code, which removes this buggy behavior
and removes implicit state.

git_cred_has_username() becomes a blacklist of credential types that do
not have a username. The only one at the moment is the 'default' one,
which is meant to call up some Microsoft magic.
2014-04-18 17:33:26 +02:00
Carlos Martín Nieto
2280b388c9 config: share the strmap on snapshot
Now that our strmap is no longer modified but replaced, we can use the
same strmap for the snapshot's values and it will be freed when we don't
need it anymore.
2014-04-18 16:13:43 +02:00
Carlos Martín Nieto
4b99b8f528 config: refcount the values map
This is mostly groundwork to let us re-use the map in the snapshots.
2014-04-18 16:12:31 +02:00