~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-updates

« back to all changes in this revision

Viewing changes to entry.c

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-04-22 13:31:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20070422133105-xg8fnm18r2cxcbg1
Tags: upstream-1.5.1.2
ImportĀ upstreamĀ versionĀ 1.5.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <sys/types.h>
2
 
#include <dirent.h>
3
1
#include "cache.h"
4
2
#include "blob.h"
5
3
 
70
68
        void *new;
71
69
        unsigned long size;
72
70
        long wrote;
73
 
        char type[20];
 
71
        enum object_type type;
74
72
 
75
 
        new = read_sha1_file(ce->sha1, type, &size);
76
 
        if (!new || strcmp(type, blob_type)) {
 
73
        new = read_sha1_file(ce->sha1, &type, &size);
 
74
        if (!new || type != OBJ_BLOB) {
77
75
                if (new)
78
76
                        free(new);
79
77
                return error("git-checkout-index: unable to read sha1 file of %s (%s)",
80
78
                        path, sha1_to_hex(ce->sha1));
81
79
        }
82
80
        switch (ntohl(ce->ce_mode) & S_IFMT) {
 
81
                char *buf;
 
82
                unsigned long nsize;
 
83
 
83
84
        case S_IFREG:
84
85
                if (to_tempfile) {
85
86
                        strcpy(path, ".merge_file_XXXXXX");
91
92
                        return error("git-checkout-index: unable to create file %s (%s)",
92
93
                                path, strerror(errno));
93
94
                }
94
 
                wrote = write(fd, new, size);
 
95
 
 
96
                /*
 
97
                 * Convert from git internal format to working tree format
 
98
                 */
 
99
                buf = new;
 
100
                nsize = size;
 
101
                if (convert_to_working_tree(ce->name, &buf, &nsize)) {
 
102
                        free(new);
 
103
                        new = buf;
 
104
                        size = nsize;
 
105
                }
 
106
 
 
107
                wrote = write_in_full(fd, new, size);
95
108
                close(fd);
96
109
                free(new);
97
110
                if (wrote != size)
98
111
                        return error("git-checkout-index: unable to write file %s", path);
99
112
                break;
100
113
        case S_IFLNK:
101
 
                if (to_tempfile) {
102
 
                        strcpy(path, ".merge_link_XXXXXX");
103
 
                        fd = mkstemp(path);
 
114
                if (to_tempfile || !has_symlinks) {
 
115
                        if (to_tempfile) {
 
116
                                strcpy(path, ".merge_link_XXXXXX");
 
117
                                fd = mkstemp(path);
 
118
                        } else
 
119
                                fd = create_file(path, 0666);
104
120
                        if (fd < 0) {
105
121
                                free(new);
106
122
                                return error("git-checkout-index: unable to create "
107
123
                                                 "file %s (%s)", path, strerror(errno));
108
124
                        }
109
 
                        wrote = write(fd, new, size);
 
125
                        wrote = write_in_full(fd, new, size);
110
126
                        close(fd);
111
127
                        free(new);
112
128
                        if (wrote != size)