Commit Graph

89 Commits

Author SHA1 Message Date
Timo Röhling
ad5611d85b New upstream version 1.5.0+ds 2022-08-28 14:13:25 +02:00
Mohammed Bilal
e579e0f707 New upstream version 1.4.3+dfsg.1 2022-05-05 10:45:21 +00:00
Pirate Praveen
c25aa7cd82 New upstream version 1.3.0+dfsg.1 2021-12-10 16:42:08 +05:30
Utkarsh Gupta
22a2d3d5ef New upstream version 1.1.0+dfsg.1 2020-12-07 04:06:37 +05:30
Jongmin Kim
ac3d33df5d New upstream version 0.28.1+dfsg.1 2019-05-12 00:29:21 +09:00
Pirate Praveen
eae0bfdcd8 New upstream version 0.27.0+dfsg.1 2018-04-26 18:06:07 +05:30
Carlos Martín Nieto
8c7c5fa585 config: add a ProgramData level
This is where portable git stores the global configuration which we can
use to adhere to it even though git isn't quite installed on the system.
2015-10-21 15:11:18 +02:00
Carlos Martín Nieto
1cef6b9f19 config: correct documentation for non-existent config file 2015-09-03 11:38:21 +02:00
Carlos Martín Nieto
5340d63d38 config: perform unlocking via git_transaction
This makes the API for commiting or discarding changes the same as for
references.
2015-08-12 04:09:38 +02:00
Carlos Martín Nieto
36f784b538 config: expose locking via the main API
This lock/unlock pair allows for the cller to lock a configuration file
to avoid concurrent operations.

It also allows for a transactional approach to updating a configuration
file. If multiple updates must be made atomically, they can be done
while the config is locked.
2015-08-12 04:09:38 +02:00
Carlos Martín Nieto
9a97f49e3a config: borrow refcounted references
This changes the get_entry() method to return a refcounted version of
the config entry, which you have to free when you're done.

This allows us to avoid freeing the memory in which the entry is stored
on a refresh, which may happen at any time for a live config.

For this reason, get_string() has been forbidden on live configs and a
new function get_string_buf() has been added, which stores the string in
a git_buf which the user then owns.

The functions which parse the string value takea advantage of the
borrowing to parse safely and then release the entry.
2015-03-03 18:35:12 +01:00
Ben Chatelain
c03e8c224c Use correct Doxygen trailing comment syntax 2015-02-10 12:44:05 -07:00
Ben Chatelain
ec7e1c93ce Fix doc comment formatting 2015-02-10 08:31:48 -07:00
Carlos Martín Nieto
eac773d92b config: add parsing and getter for paths 2015-01-14 19:36:50 +01:00
Carlos Martín Nieto
a295bd2dc4 doc: add documentation to all the public structs and enums
This makes them show up in the reference, even if the text itself isn't
the most descriptive.

These have been found with

    grep -Przon '\n\ntypedef struct.*?\{' -- include
    grep -Przon '\n\ntypedef enum.*?\{' -- include
2014-12-06 03:44:40 +01:00
Will Stamper
b874629b2d Spelling fixes 2014-12-04 21:06:59 -06:00
Carlos Martín Nieto
55cb499972 config: remove the refresh function and backend field
We have been refreshing on read and write for a while now, so
git_config_refresh() is at best a no-op, and might just end up wasting
cycles.
2014-10-23 19:05:02 +02:00
Carlos Martín Nieto
c20d71eac9 config: document the how long the pointers are valid for 2014-04-18 16:07:33 +02:00
Carlos Martín Nieto
55ebd7d369 config: implement config snapshotting
In order to have consistent views of the config files for remotes,
submodules et al. and a configuration that represents what is currently
stored on-disk, we need a way to provide a view of the configuration
that does not change.

The goal here is to provide the snapshotting part by creating a
read-only copy of the state of the configuration at a particular point
in time, which does not change when a repository's main config changes.
2014-04-18 16:03:01 +02:00
Carlos Martín Nieto
ee550477d1 config: use git_buf for returning paths
Again, we already did this internally, so simply remove the conversions.
2014-01-27 04:44:05 +01:00
Russell Belfer
373cf6a932 Update docs for new callback return value behavior 2013-12-11 10:57:50 -08:00
Russell Belfer
25e0b1576d Remove converting user error to GIT_EUSER
This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
2013-12-11 10:57:49 -08:00
Daniel Rodríguez Troitiño
3793fa9b18 Fix saving remotes with several fetch/push ref specs.
At some moment git_config_delete_entry lost the ability to delete one entry of
a multivar configuration. The moment you had more than one fetch or push
ref spec for a remote you will not be able to save that remote anymore. The
changes in network::remote::remotes::save show that problem.

I needed to create a new git_config_delete_multivar because I was not able to
remove one or several entries of a multivar config with the current API.
Several tries modifying how git_config_set_multivar(..., NULL) behaved were
not successful.

git_config_delete_multivar is very similar to git_config_set_multivar, and
delegates into config_delete_multivar of config_file. This function search
for the cvar_t that will be deleted, storing them in a temporal array, and
rebuilding the linked list. After calling config_write to delete the entries,
the cvar_t stored in the temporal array are freed.

There is a little fix in config_write, it avoids an infinite loop when using
a regular expression (case for the multivars). This error was found by the
test network::remote::remotes::tagopt.
2013-11-01 00:08:52 +01:00
Carlos Martín Nieto
f4be8209af config: don't special-case the multivar iterator
Build it on top of the normal iterator instead, which lets use re-use
a lot of code.
2013-08-14 00:45:05 +02:00
Carlos Martín Nieto
54f3a572b4 config: introduce a regex-filtering iterator 2013-08-12 11:40:57 +02:00
Carlos Martín Nieto
5880962d90 config: introduce _iterator_new()
As the name suggests, it iterates over all the entries
2013-08-12 11:40:57 +02:00
Carlos Martín Nieto
1e96c9d534 config: add _next() and _iterator_free()
Make it look like the refs iterator API.
2013-08-08 20:47:06 +02:00
Carlos Martín Nieto
99dfb538ad config: working multivar iterator
Implement the foreach version as a wrapper around the iterator.
2013-08-08 20:38:42 +02:00
Carlos Martín Nieto
eba7399251 config: move next() and free() into the iterator
Like we have in the references iterator, next and free belong in the
iterator itself.
2013-08-08 14:39:32 +02:00
Carlos Martín Nieto
4efa32903a config: get_multivar -> get_multivar_foreach
The plain function will return an iterator, so move this one out of
the way.
2013-08-08 13:57:01 +02:00
Carlos Martín Nieto
4d588d9713 Don't typedef a pointer
Make the iterator structure opaque and make sure it compiles.
2013-08-08 11:40:41 +02:00
Nico von Geyso
a603c19157 replaced foreach() with non callback based iterations in git_config_backend
new functions in struct git_config_backend:
  * iterator_new(...)
  * iterator_free(...)
  * next(...)

The old callback based foreach style can still be used with `git_config_backend_foreach_match`
2013-08-08 11:14:53 +02:00
Andreas Linde
e196716457 Fixed most documentation header bugs
Fixed a few header @param and @return typos with the help of -Wdocumentation in Xcode.

The following warnings have not been fixed:
common.h:213 - Not sure how the documentation format is for '...'
notes.h:102 - Correct @param name but empty text
notes.h:111 - Correct @param name but empty text
pack.h:140 - @return missing text
pack.h:148 - @return missing text
2013-06-24 15:33:41 +02:00
Sven Strickroth
76b893b653 Add high(est) config level for application specific config files
Some tools use an extra level to maintain an application specific config files on top of the normal ones. Revision 16adc9fade broke this.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-06-11 23:37:02 +02:00
Russell Belfer
16adc9fade Typedef git_config_level_t and use it everywhere
The GIT_CONFIG_LEVEL constants actually work well as an enum
because they are mutually exclusive, so this adds a typedef to
the enum and uses that everywhere that one of these constants are
expected, instead of the old code that typically used an unsigned
int.
2013-05-24 10:35:58 -07:00
Linquize
0cb16fe924 Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
Carlos Martín Nieto
5d8318875f config: convenience function to open global/xdg
The rules for which one to open is a bit silly, so let's make it
easier for our users.
2013-05-07 21:42:56 +02:00
Russell Belfer
83041c711c Move git_config_backend to include/git2/sys
Moving backend implementor objects into include/git2/sys so the
APIs can be isolated from the ones that normal libgit2 users
would be likely to use.
2013-04-21 11:50:55 -07:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Kevin Sawicki
7eb222fc7d Correct typos in documentation 2013-01-06 10:39:35 -08:00
Ben Straub
fac43c54a6 Allow compilation as C++ 2012-12-06 19:41:52 -08:00
Ben Straub
bde336ea51 Add version fields and init macros for public input structs. 2012-11-30 12:55:45 -08:00
Ben Straub
54b2a37ac7 Clean up config.h 2012-11-27 13:18:28 -08:00
nulltoken
270160b91a config: Opening a nonexistent file returns ENOTFOUND 2012-11-17 18:30:34 -08:00
nulltoken
d36451c9d4 config: Make git_config_file__ondisk() internal 2012-11-17 12:34:15 -08:00
Carlos Martín Nieto
3ee078c0f7 config: rename get_config_entry -> config_entry
We're already in the git_config namespace, there is no need to repeat
it.
2012-11-13 13:46:17 -08:00
Russell Belfer
744cc03e2b Add git_config_refresh() API to reload config
This adds a new API that allows users to reload the config if the
file has changed on disk.  A new config callback function to
refresh the config was added.

The modified time and file size are used to test if the file needs
to be reloaded (and are now stored in the disk backend object).

In writing tests, just using mtime was a problem / race, so I
wanted to check file size as well.  To support that, I extended
`git_futils_readbuffer_updated` to optionally check file size in
addition to mtime, and I added a new function `git_filebuf_stats`
to fetch the mtime and size for an open filebuf (so that the
config could be easily refreshed after a write).

Lastly, I moved some similar file checking code for attributes
into filebuf.  It is still only being used for attrs, but it
seems potentially reusable, so I thought I'd move it over.
2012-10-30 12:11:23 -07:00
yorah
a1abe66aca Add config level support in the config API
Added `struct git_config_entry`: a git_config_entry contains the key, the value, and the config file level from which a config element was found.
Added `git_config_open_level`: build a single-level focused config object from a multi-level one.

We are now storing `git_config_entry`s in the khash of the config_file
2012-10-23 12:48:38 +02:00
Sven Strickroth
4258d4832b Rename xdr to xdg
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2012-10-02 17:21:07 +02:00
Sven Strickroth
8b4f9b1758 Correctly read xdr compatible %HOME%/.config/git/config config file
This file is not just read if the global config file (%HOME%/.gitconfig)
is not found, however, it is used everytime but with lower priority.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2012-09-24 18:59:00 +02:00